* Support function links to function overloads. * Improve readability of headings for functions.
3.3 KiB
Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
QuerySnapshot class
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
| Method | Modifiers | Description |
|---|---|---|
| forEach(callback, thisArg) | Enumerates all of the documents in the QuerySnapshot. |
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