Property

firestore

non-null firebase.firestore.Firestore

The Firestore for the Cloud Firestore database (useful for performing transactions, etc.).

Methods

endAt

endAt(snapshotOrVarArgs) returns firebase.firestore.Query

Creates a new query where the results end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

Parameter

snapshotOrVarArgs

(non-null firebase.firestore.DocumentSnapshot or repeatable any type)

The snapshot of the document the query results should end at or the field values to end this query at, in order of the query's order by.

Returns

non-null firebase.firestore.Query The created query.

endBefore

endBefore(snapshotOrVarArgs) returns firebase.firestore.Query

Creates a new query where the results end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

Parameter

snapshotOrVarArgs

(non-null firebase.firestore.DocumentSnapshot or repeatable any type)

The snapshot of the document the query results should end before or the field values to end this query before, in order of the query's order by.

Returns

non-null firebase.firestore.Query The created query.

get

get(options) returns firebase.firestore.QuerySnapshot

Executes the query and returns the results as a QuerySnapshot.

Parameter

options

Optional

firebase.firestore.GetOptions

An options object to configure how the data is retrieved.

Value must not be null.

Returns

non-null firebase.firestore.QuerySnapshot A promise that will be resolved with the results of the query.

limit

limit(limit) returns firebase.firestore.Query

Creates a new query where the results are limited to the specified number of documents.

Parameter

limit

number

The maximum number of items to return.

Returns

non-null firebase.firestore.Query The created query.

onSnapshot

onSnapshot(optionsOrObserverOrOnNext, observerOrOnNextOrOnError, onError) returns function()

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

Parameter

optionsOrObserverOrOnNext

(non-null firebase.firestore.SnapshotListenOptions, non-null Object, or function(non-null firebase.firestore.DocumentSnapshot))

This can be an observer object or an onNext function callback. It can also be an options object containing { includeMetadataChanges: true } to opt into events even when only metadata changed.

observerOrOnNextOrOnError

(non-null Object, function(non-null firebase.firestore.DocumentSnapshot), or function(non-null firebase.FirebaseError))

If you provided options, this will be an observer object or your onNext callback. Else, it is an optional onError callback.

onError

Optional

function(non-null firebase.FirebaseError)

If you didn't provide options and didn't use an observer object, this is the optional onError callback.

Returns

non-null function() An unsubscribe function that can be called to cancel the snapshot listener.

orderBy

orderBy(fieldPath, directionStr) returns firebase.firestore.Query

Creates a new query where the results are sorted by the specified field, in descendin or ascending order.

Parameter

fieldPath

(string or non-null firebase.firestore.FieldPath)

The field to sort by.

directionStr

Optional

string

Optional direction to sort by (asc or desc). If not specified, the default order is ascending.

Returns

non-null firebase.firestore.Query The created query.

startAfter

startAfter(snapshotOrVarArgs) returns firebase.firestore.Query

Creates a new query where the results start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

Parameter

snapshotOrVarArgs

(non-null firebase.firestore.DocumentSnapshot or repeatable any type)

The snapshot of the document to start after or the field values to start this query after, in order of the query's order by.

Returns

non-null firebase.firestore.Query The created query.

startAt

startAt(snapshotOrVarArgs) returns firebase.firestore.Query

Creates a new query where the results start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

Parameter

snapshotOrVarArgs

(non-null firebase.firestore.DocumentSnapshot or repeatable any type)

The snapshot of the document you want the query to start at or the field values to start this query at, in order of the query's order by.

Returns

non-null firebase.firestore.Query The created query.

where

where(fieldPath, opStr, value) returns firebase.firestore.Query

Creates a new query that returns only documents that include the specified fields and where the values satisfy the constraints provided.

Parameter

fieldPath

(string or non-null firebase.firestore.FieldPath)

The path to compare.

opStr

string

The operation string. The operators "<", "<=", "==", ">", and ">=" can be used to compare a field to a specified value. The operator "array-contains" can be used to find documents where a field is an array and contains a specified value.

value

any type

The value for comparison.

Returns

non-null firebase.firestore.Query The created query.