QuerySnapshot class
Stay organized with collections
Save and categorize content based on your preferences.
A QuerySnapshot
contains zero or more DocumentSnapshot
objects representing the results of a query. The documents can be accessed as an array via the docs
property or enumerated using the forEach
method. The number of documents can be determined via the empty
and size
properties.
Signature:
export declare class QuerySnapshot<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData>
Properties
Property |
Modifiers |
Type |
Description |
docs |
|
Array<QueryDocumentSnapshot<AppModelType, DbModelType>> |
An array of all the documents in the QuerySnapshot . |
empty |
|
boolean |
True if there are no documents in the QuerySnapshot . |
query |
|
Query<AppModelType, DbModelType> |
The query on which you called getDocs() in order to get this QuerySnapshot . |
size |
|
number |
The number of documents in the QuerySnapshot . |
Methods
QuerySnapshot.docs
An array of all the documents in the QuerySnapshot
.
Signature:
get docs(): Array<QueryDocumentSnapshot<AppModelType, DbModelType>>;
QuerySnapshot.empty
True if there are no documents in the QuerySnapshot
.
Signature:
get empty(): boolean;
QuerySnapshot.query
The query on which you called getDocs() in order to get this QuerySnapshot
.
Signature:
readonly query: Query<AppModelType, DbModelType>;
QuerySnapshot.size
The number of documents in the QuerySnapshot
.
Signature:
get size(): number;
QuerySnapshot.forEach()
Enumerates all of the documents in the QuerySnapshot
.
Signature:
forEach(callback: (result: QueryDocumentSnapshot<AppModelType, DbModelType>) => void, thisArg?: unknown): void;
Parameters
Parameter |
Type |
Description |
callback |
(result: QueryDocumentSnapshot<AppModelType, DbModelType>) => void |
A callback to be called with a QueryDocumentSnapshot for each document in the snapshot. |
thisArg |
unknown |
The this binding for the callback. |
Returns:
void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-19 UTC.
[null,null,["Last updated 2024-01-19 UTC."],[],[],null,["# QuerySnapshot class\n\nA `QuerySnapshot` contains zero or more `DocumentSnapshot` objects representing the results of a query. The documents can be accessed as an array via the `docs` property or enumerated using the `forEach` method. The number of documents can be determined via the `empty` and `size` properties.\n\n**Signature:** \n\n export declare class QuerySnapshot\u003cAppModelType = DocumentData, DbModelType extends DocumentData = DocumentData\u003e \n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|---------------------------------------------------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|\n| [docs](./firestore_lite.querysnapshot.md#querysnapshotdocs) | | Array\\\u003c[QueryDocumentSnapshot](./firestore_lite.querydocumentsnapshot.md#querydocumentsnapshot_class)\\\u003cAppModelType, DbModelType\\\u003e\\\u003e | An array of all the documents in the `QuerySnapshot`. |\n| [empty](./firestore_lite.querysnapshot.md#querysnapshotempty) | | boolean | True if there are no documents in the `QuerySnapshot`. |\n| [query](./firestore_lite.querysnapshot.md#querysnapshotquery) | | [Query](./firestore_lite.query.md#query_class)\\\u003cAppModelType, DbModelType\\\u003e | The query on which you called [getDocs()](./firestore_.md#getdocs_4e56953) in order to get this `QuerySnapshot`. |\n| [size](./firestore_lite.querysnapshot.md#querysnapshotsize) | | number | The number of documents in the `QuerySnapshot`. |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|--------------------------------------------------------------------------------------|-----------|---------------------------------------------------------|\n| [forEach(callback, thisArg)](./firestore_lite.querysnapshot.md#querysnapshotforeach) | | Enumerates all of the documents in the `QuerySnapshot`. |\n\nQuerySnapshot.docs\n------------------\n\nAn array of all the documents in the `QuerySnapshot`.\n\n**Signature:** \n\n get docs(): Array\u003cQueryDocumentSnapshot\u003cAppModelType, DbModelType\u003e\u003e;\n\nQuerySnapshot.empty\n-------------------\n\nTrue if there are no documents in the `QuerySnapshot`.\n\n**Signature:** \n\n get empty(): boolean;\n\nQuerySnapshot.query\n-------------------\n\nThe query on which you called [getDocs()](./firestore_.md#getdocs_4e56953) in order to get this `QuerySnapshot`.\n\n**Signature:** \n\n readonly query: Query\u003cAppModelType, DbModelType\u003e;\n\nQuerySnapshot.size\n------------------\n\nThe number of documents in the `QuerySnapshot`.\n\n**Signature:** \n\n get size(): number;\n\nQuerySnapshot.forEach()\n-----------------------\n\nEnumerates all of the documents in the `QuerySnapshot`.\n\n**Signature:** \n\n forEach(callback: (result: QueryDocumentSnapshot\u003cAppModelType, DbModelType\u003e) =\u003e void, thisArg?: unknown): void;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|\n| callback | (result: [QueryDocumentSnapshot](./firestore_lite.querydocumentsnapshot.md#querydocumentsnapshot_class)\\\u003cAppModelType, DbModelType\\\u003e) =\\\u003e void | A callback to be called with a `QueryDocumentSnapshot` for each document in the snapshot. |\n| thisArg | unknown | The `this` binding for the callback. |\n\n**Returns:**\n\nvoid"]]