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:

exportdeclareclassQuerySnapshot<AppModelType=DocumentData,DbModelTypeextendsDocumentData=DocumentData>

Properties

PropertyModifiersTypeDescription
docsArray<QueryDocumentSnapshot<AppModelType, DbModelType>>An array of all the documents in the QuerySnapshot.
emptybooleanTrue if there are no documents in the QuerySnapshot.
queryQuery<AppModelType, DbModelType>The query on which you called getDocs() in order to get this QuerySnapshot.
sizenumberThe number of documents in the QuerySnapshot.

Methods

MethodModifiersDescription
forEach(callback, thisArg)Enumerates all of the documents in the QuerySnapshot.

QuerySnapshot.docs

An array of all the documents in the QuerySnapshot.

Signature:

getdocs():Array<QueryDocumentSnapshot<AppModelType,DbModelType>>;

QuerySnapshot.empty

True if there are no documents in the QuerySnapshot.

Signature:

getempty():boolean;

QuerySnapshot.query

The query on which you called getDocs() in order to get this QuerySnapshot.

Signature:

readonlyquery:Query<AppModelType,DbModelType>;

QuerySnapshot.size

The number of documents in the QuerySnapshot.

Signature:

getsize():number;

QuerySnapshot.forEach()

Enumerates all of the documents in the QuerySnapshot.

Signature:

forEach(callback:(result:QueryDocumentSnapshot<AppModelType,DbModelType>)=>void,thisArg?:unknown):void;

Parameters

ParameterTypeDescription
callback(result: QueryDocumentSnapshot<AppModelType, DbModelType>) => voidA callback to be called with a QueryDocumentSnapshot for each document in the snapshot.
thisArgunknownThe this binding for the callback.

Returns:

void