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<T>
,
_readTime
:
Timestamp
,
_size
:
number
,
docs
:
()
=
>
Array<QueryDocumentSnapshot<T>
> ,
changes
:
()
=
>
Array<DocumentChange<T>
> );
Constructs a new instance of the QuerySnapshot
class
Name | Description |
_query | Query
<T>
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
<T>>
A callback returning a sorted array of documents matching this query |
changes | () => Array
< DocumentChange
<T>>
A callback returning a sorted array of document change events for this snapshot. |
Properties
docs
get
docs
()
:
Array<QueryDocumentSnapshot<T>
> ;
An array of all the documents in this QuerySnapshot.
{Array.
Type | Description |
---|---|
Array < QueryDocumentSnapshot <T>> |
empty
get
empty
()
:
boolean
;
True if there are no documents in the QuerySnapshot.
{boolean} QuerySnapshot#empty
Type | Description |
---|---|
boolean |
query
get
query
()
:
Query<T>
;
The query on which you called get() or onSnapshot() in order to get this QuerySnapshot.
{Query} QuerySnapshot#query
Type | Description |
---|---|
Query <T> |
readTime
get
readTime
()
:
Timestamp
;
The time this query snapshot was obtained.
{Timestamp} QuerySnapshot#readTime
Type | Description |
---|---|
Timestamp |
size
get
size
()
:
number
;
The number of documents in the QuerySnapshot.
{number} QuerySnapshot#size
Type | Description |
---|---|
number |
Methods
docChanges()
docChanges
()
:
Array<DocumentChange<T>
> ;
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.
Type | Description |
---|---|
Array < DocumentChange <T>> |
forEach(callback, thisArg)
forEach
(
callback
:
(
result
:
firestore
.
QueryDocumentSnapshot<T>
)
=
>
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.
Name | Description |
callback | (result: FirebaseFirestore.QueryDocumentSnapshot
<T>) => void
A callback to be called with a [QueryDocumentSnapshot] QueryDocumentSnapshot for each document in the snapshot. |
thisArg | unknown
The |
Type | Description |
---|---|
void |
isEqual(other)
isEqual
(
other
:
firestore
.
QuerySnapshot<T>
)
:
boolean
;
Returns true if the document data in this QuerySnapshot
is equal to the provided value.
Name | Description |
other | FirebaseFirestore.QuerySnapshot
<T>
The value to compare against. {boolean} true if this |
Type | Description |
---|---|
boolean |