Read multiple documents
Last updated
Last updated
To read multiple documents in a collection, you'll need a reference to that collection.
Once you have a reference, you can use the get
method to fetch a snapshot of that collection, which will contain snapshots for all of the documents in that collection.
When building a reference to a collection, you can add queries to the reference which can limit the data returned by the reference. To add a query, use the where
method on a collection reference.
You can add multiple queries by calling where
multiple times. These queries are applied as AND
queries. OR
queries are not possible with the SDK at this time.
The following values can be used for the comparator (the second parameter) of the call to where
...
You can change the order documents are returned to you in a snapshot by calling the orderBy
function on the reference.
By default, only the first 1000 documents will be returned in a snapshot. You can change this by calling the limit
function on the reference.
By default, there is no server-enforced upper limit for the number of documents that can be returned in a query. Performance may suffer with large limit values.
Value
Description
==
Finds documents where field
is equal to value
.
!=
Finds documents where field
is not equal to value
.
>
Finds documents where field
is greater than value
.
<
Finds documents where field
is less than value
.
>=
Finds documents where field
is greater than or equal to value
.
<=
Finds documents where field
is less than or equal to value
.
array-contains
Finds documents where an array, field
, contains value
.
array-not-contains
Finds documents where an array, field
, does not contain value
.
matches
Finds documents where field
matches regex expression value
.
not-matches
Finds documents where field
does not match regex expression value
.