A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/nodejs/docs/reference/firestore/latest/firestore/querysnapshot below:

Class QuerySnapshot (7.11.0) | Node.js client library

Skip to main content Class QuerySnapshot (7.11.0)

Stay organized with collections Save and categorize content based on your preferences.

A QuerySnapshot contains zero or more [QueryDocumentSnapshot]QueryDocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the [documents] property or enumerated using the [forEach] method. The number of documents can be determined via the [empty] and [size] properties.

QuerySnapshot

Package@google-cloud/firestore Constructors (constructor)(_query, _readTime, _size, docs, changes)
constructor(_query: Query<AppModelType, DbModelType>, _readTime: Timestamp, _size: number, docs: () => Array<QueryDocumentSnapshot<AppModelType, DbModelType>>, changes: () => Array<DocumentChange<AppModelType, DbModelType>>);

Constructs a new instance of the QuerySnapshot class

Parameters Name Description _query Query<AppModelType, DbModelType>

The originating query.

_readTime Timestamp

The time when this query snapshot was obtained.

_size number

The number of documents in the result set.

docs () => Array<QueryDocumentSnapshot<AppModelType, DbModelType>>

A callback returning a sorted array of documents matching this query

changes () => Array<DocumentChange<AppModelType, DbModelType>>

A callback returning a sorted array of document change events for this snapshot.

Properties docs
get docs(): Array<QueryDocumentSnapshot<AppModelType, DbModelType>>;

An array of all the documents in this QuerySnapshot.

{Array.

Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.get().then(querySnapshot => {
  let docs = querySnapshot.docs;
  for (let doc of docs) {
    console.log(`Document found at path: ${doc.ref.path}`);
  }
});
empty

True if there are no documents in the QuerySnapshot.

{boolean} QuerySnapshot#empty

Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.get().then(querySnapshot => {
  if (querySnapshot.empty) {
    console.log('No documents found.');
  }
});
query
get query(): Query<AppModelType, DbModelType>;

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

{Query} QuerySnapshot#query

Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.limit(10).get().then(querySnapshot => {
  console.log(`Returned first batch of results`);
  let query = querySnapshot.query;
  return query.offset(10).get();
}).then(() => {
  console.log(`Returned second batch of results`);
});
readTime
get readTime(): Timestamp;

The time this query snapshot was obtained.

{Timestamp} QuerySnapshot#readTime

Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.get().then((querySnapshot) => {
  let readTime = querySnapshot.readTime;
  console.log(`Query results returned at '${readTime.toDate()}'`);
});
size

The number of documents in the QuerySnapshot.

{number} QuerySnapshot#size

Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.get().then(querySnapshot => {
  console.log(`Found ${querySnapshot.size} documents.`);
});
Methods docChanges()
docChanges(): Array<DocumentChange<AppModelType, DbModelType>>;

Returns an array of the documents changes since the last snapshot. If this is the first snapshot, all documents will be in the list as added changes.

{Array.

Returns Type Description Array<DocumentChange<AppModelType, DbModelType>> Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.onSnapshot(querySnapshot => {
  let changes = querySnapshot.docChanges();
  for (let change of changes) {
    console.log(`A document was ${change.type}.`);
  }
});
forEach(callback, thisArg)
forEach(callback: (result: firestore.QueryDocumentSnapshot<AppModelType, DbModelType>) => void, thisArg?: unknown): void;

Enumerates all of the documents in the QuerySnapshot. This is a convenience method for running the same callback on each QueryDocumentSnapshot that is returned.

Parameters Name Description callback (result: FirebaseFirestore.QueryDocumentSnapshot<AppModelType, DbModelType>) => void

A callback to be called with a [QueryDocumentSnapshot]QueryDocumentSnapshot for each document in the snapshot.

thisArg unknown

The this binding for the callback..

Returns Type Description void Example

let query = firestore.collection('col').where('foo', '==', 'bar');

query.get().then(querySnapshot => {
  querySnapshot.forEach(documentSnapshot => {
    console.log(`Document found at path: ${documentSnapshot.ref.path}`);
  });
});
isEqual(other)
isEqual(other: firestore.QuerySnapshot<AppModelType, DbModelType>): boolean;

Returns true if the document data in this QuerySnapshot is equal to the provided value.

Parameter Name Description other FirebaseFirestore.QuerySnapshot<AppModelType, DbModelType>

The value to compare against. {boolean} true if this QuerySnapshot is equal to the provided value.

Returns Type Description boolean

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 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4