Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

§Classes

AggregateField

Represents an aggregation that can be performed by Firestore.

AggregateQuerySnapshot

The results of executing an aggregation query.

Bytes

An immutable object representing an array of bytes.

CollectionReference

A CollectionReference object can be used for adding documents, getting document references, and querying for documents (using {@link (query:1)}).

DocumentReference

A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist.

DocumentSnapshot

A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with .data() or .get(<field>) to get a specific field.

FieldPath

A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top-level field in the document), or a list of field names (referring to a nested field in the document).

FieldValue abstract

Sentinel values that can be used when writing document fields with set() or update().

Firestore

The Cloud Firestore service interface.

FirestoreError

An error returned by a Firestore operation.

GeoPoint

An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.

LoadBundleTask

Represents the task of loading a Firestore bundle. It provides progress of bundle loading, as well as task completion and error events.

PersistentCacheIndexManager

A PersistentCacheIndexManager for configuring persistent cache indexes used for local query execution.

Query

A Query refers to a query which you can read or listen to. You can also construct refined Query objects by adding filters and ordering.

QueryCompositeFilterConstraint

A QueryCompositeFilterConstraint is used to narrow the set of documents returned by a Firestore query by performing the logical OR or AND of multiple QueryFieldFilterConstraints or QueryCompositeFilterConstraints. QueryCompositeFilterConstraints are created by invoking or or and and can then be passed to {@link (query:1)} to create a new query instance that also contains the QueryCompositeFilterConstraint.

QueryConstraint abstract

A QueryConstraint is used to narrow the set of documents returned by a Firestore query. QueryConstraints are created by invoking where, orderBy, {@link (startAt:1)}, {@link (startAfter:1)}, {@link (endBefore:1)}, {@link (endAt:1)}, limit, limitToLast and can then be passed to {@link (query:1)} to create a new query instance that also contains this QueryConstraint.

QueryDocumentSnapshot

A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of a query. The document is guaranteed to exist and its data can be extracted with .data() or .get(<field>) to get a specific field.

QueryEndAtConstraint

A QueryEndAtConstraint is used to exclude documents from the end of a result set returned by a Firestore query. QueryEndAtConstraints are created by invoking {@link (endAt:1)} or {@link (endBefore:1)} and can then be passed to {@link (query:1)} to create a new query instance that also contains this QueryEndAtConstraint.

QueryFieldFilterConstraint

A QueryFieldFilterConstraint is used to narrow the set of documents returned by a Firestore query by filtering on one or more document fields. QueryFieldFilterConstraints are created by invoking where and can then be passed to {@link (query:1)} to create a new query instance that also contains this QueryFieldFilterConstraint.

QueryLimitConstraint

A QueryLimitConstraint is used to limit the number of documents returned by a Firestore query. QueryLimitConstraints are created by invoking limit or limitToLast and can then be passed to {@link (query:1)} to create a new query instance that also contains this QueryLimitConstraint.

QueryOrderByConstraint

A QueryOrderByConstraint is used to sort the set of documents returned by a Firestore query. QueryOrderByConstraints are created by invoking orderBy and can then be passed to {@link (query:1)} to create a new query instance that also contains this QueryOrderByConstraint.

QuerySnapshot

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.

QueryStartAtConstraint

A QueryStartAtConstraint is used to exclude documents from the start of a result set returned by a Firestore query. QueryStartAtConstraints are created by invoking {@link (startAt:1)} or {@link (startAfter:1)} and can then be passed to {@link (query:1)} to create a new query instance that also contains this QueryStartAtConstraint.

SnapshotMetadata

Metadata about a snapshot, describing the state of the snapshot.

Timestamp

A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.

Transaction

A reference to a transaction.

VectorValue

Represents a vector type in Firestore documents. Create an instance with FieldValue.vector.

WriteBatch

A write batch, used to perform multiple writes as a single atomic unit.

§Variables

CACHE_SIZE_UNLIMITED

Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the Firestore instance.

§Functions

addDoc

Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically.

aggregateFieldEqual

Compares two 'AggregateField` instances for equality.

aggregateQuerySnapshotEqual

Compares two AggregateQuerySnapshot instances for equality.

and

Creates a new QueryCompositeFilterConstraint that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters.

arrayRemove

Returns a special value that can be used with {@link (setDoc:1)} or updateDoc:1 that tells the server to remove the given elements from any array value that already exists on the server. All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array.

arrayUnion

Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link

average

Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

clearIndexedDbPersistence

Clears the persistent storage. This includes pending writes and cached documents.

collection

Gets a CollectionReference instance that refers to the collection at the specified absolute path.

collectionGroup

Creates and returns a new Query instance that includes all documents in the database that are contained in a collection or subcollection with the given collectionId.

connectFirestoreEmulator

Modify this instance to communicate with the Cloud Firestore emulator.

count

Create an AggregateField object that can be used to compute the count of documents in the result set of a query.

deleteAllPersistentCacheIndexes

Removes all persistent cache indexes.

deleteDoc

Deletes the document referred to by the specified DocumentReference.

deleteField

Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or {@link @firebase/firestore/lite#(setDoc:1)} with {merge: true} to mark a field for deletion.

disableNetwork

Disables network usage for this instance. It can be re-enabled via enableNetwork. While the network is disabled, any snapshot listeners, getDoc() or getDocs() calls will return results from cache, and any write operations will be queued until the network is restored.

disablePersistentCacheIndexAutoCreation

Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect.

doc

Gets a DocumentReference instance that refers to the document at the specified absolute path.

documentId

Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID.

enableIndexedDbPersistence deprecated

Attempts to enable persistent storage, if possible.

enableMultiTabIndexedDbPersistence deprecated

Attempts to enable multi-tab persistent storage, if possible. If enabled across all tabs, all operations share access to local persistence, including shared execution of queries and latency-compensated local document updates across all connected instances.

enableNetwork

Re-enables use of the network for this Firestore instance after a prior call to disableNetwork.

enablePersistentCacheIndexAutoCreation

Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.

endAt

Creates a QueryEndAtConstraint that modifies the result set to 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 the query.

endBefore

Creates a QueryEndAtConstraint that modifies the result set to 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 the query.

getAggregateFromServer

Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.

getCountFromServer

Calculates the number of documents in the result set of the given query without actually downloading the documents.

getDoc

Reads the document referred to by this DocumentReference.

getDocFromCache

Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached.

getDocFromServer

Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available.

getDocs

Executes the query and returns the results as a QuerySnapshot.

getDocsFromCache

Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached.

getDocsFromServer

Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available.

getFirestore

Returns the existing default Firestore instance that is associated with the default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new instance with default settings.

getPersistentCacheIndexManager

Returns the PersistentCache Index Manager used by the given Firestore object.

increment

Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link

initializeFirestore

Initializes a new instance of Firestore with the provided settings. Can only be called before any other function, including {@link (getFirestore:1)}. If the custom settings are empty, this function is equivalent to calling {@link (getFirestore:1)}.

limit

Creates a QueryLimitConstraint that only returns the first matching documents.

limitToLast

Creates a QueryLimitConstraint that only returns the last matching documents.

loadBundle

Loads a Firestore bundle into the local cache.

memoryEagerGarbageCollector

Creates an instance of MemoryEagerGarbageCollector. This is also the default garbage collector unless it is explicitly specified otherwise.

memoryLocalCache

Creates an instance of MemoryLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.

memoryLruGarbageCollector

Creates an instance of MemoryLruGarbageCollector.

namedQuery

Reads a Firestore Query from local cache, identified by the given name.

onSnapshot

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

onSnapshotsInSync

Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.

or

Creates a new QueryCompositeFilterConstraint that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters.

orderBy

Creates a QueryOrderByConstraint that sorts the query result by the specified field, optionally in descending order instead of ascending.

persistentLocalCache

Creates an instance of PersistentLocalCache. The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.

persistentMultipleTabManager

Creates an instance of PersistentMultipleTabManager.

persistentSingleTabManager

Creates an instance of PersistentSingleTabManager.

query

Creates a new immutable instance of Query that is extended to also include additional query constraints.

queryEqual

Returns true if the provided queries point to the same collection and apply the same constraints.

refEqual

Returns true if the provided references are equal.

runTransaction

Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, Cloud Firestore retries the updateFunction. If it fails to commit after 5 attempts, the transaction fails.

serverTimestamp

Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to include a server-generated timestamp in the written data.

setDoc

Writes to the document referred to by this DocumentReference. If the document does not yet exist, it will be created.

setIndexConfiguration deprecated

Configures indexing for local query execution. Any previous index configuration is overridden. The Promise resolves once the index configuration has been persisted.

setLogLevel

Sets the verbosity of Cloud Firestore logs (debug, error, or silent).

snapshotEqual

Returns true if the provided snapshots are equal.

startAfter

Creates a QueryStartAtConstraint that modifies the result set to 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 the query.

startAt

Creates a QueryStartAtConstraint that modifies the result set to 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 this query.

sum

Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

terminate

Terminates the provided Firestore instance.

updateDoc

Updates fields in the document referred to by the specified DocumentReference. The update will fail if applied to a document that does not exist.

vector

Creates a new VectorValue constructed with a copy of the given array of numbers.

waitForPendingWrites

Waits until all currently pending writes for the active user have been acknowledged by the backend.

where

Creates a QueryFieldFilterConstraint that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided.

writeBatch

Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500.

§Interfaces

AggregateSpec

Specifies a set of aggregations and their aliases.

DocumentChange

A DocumentChange represents a change to the documents matching a query. It contains the document affected and the type of change that occurred.

DocumentData

Document data (for use with {@link @firebase/firestore/lite#(setDoc:1)}) consists of fields mapped to values.

ExperimentalLongPollingOptions

Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.

FirestoreDataConverter

Converter used by withConverter() to transform user objects of type AppModelType into Firestore data of type DbModelType.

FirestoreSettings

Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods.

Index deprecated

The SDK definition of a Firestore index.

IndexConfiguration deprecated

A list of Firestore indexes to speed up local query execution.

IndexField deprecated

A single field element in an index configuration.

LoadBundleTaskProgress

Represents a progress update or a final state from loading bundles.

MemoryCacheSettings

An settings object to configure an MemoryLocalCache instance.

MemoryEagerGarbageCollector

A garbage collector deletes documents whenever they are not part of any active queries, and have no local mutations attached to them.

MemoryLocalCache

Provides an in-memory cache to the SDK. This is the default cache unless explicitly configured otherwise.

MemoryLruGarbageCollector

A garbage collector deletes Least-Recently-Used documents in multiple batches.

PersistenceSettings

Settings that can be passed to enableIndexedDbPersistence() to configure Firestore persistence.

PersistentCacheSettings

An settings object to configure an PersistentLocalCache instance.

PersistentLocalCache

Provides a persistent cache backed by IndexedDb to the SDK.

PersistentMultipleTabManager

A tab manager supporting multiple tabs. SDK will synchronize queries and mutations done across all tabs using the SDK.

PersistentSingleTabManager

A tab manager supporting only one tab, no synchronization will be performed across tabs.

PersistentSingleTabManagerSettings

Type to configure an PersistentSingleTabManager instance.

SnapshotListenOptions

An options object that can be passed to {@link (onSnapshot:1)} and QuerySnapshot.docChanges to control which types of changes to include in the result set.

SnapshotOptions

Options that configure how data is retrieved from a DocumentSnapshot (for example the desired behavior for server timestamps that have not yet been set to their final value).

TransactionOptions

Options to customize transaction behavior.

Unsubscribe

A function returned by onSnapshot() that removes the listener when invoked.

§Type Aliases

AddPrefixToKeys

Returns a new map where every key is prefixed with the outer key appended to a dot.

AggregateFieldType

The union of all AggregateField types that are supported by Firestore.

AggregateSpecData

A type whose keys are taken from an AggregateSpec, and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec.

AggregateType

Union type representing the aggregate type to be performed.

ChildUpdateFields

Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}.

DocumentChangeType

The type of a DocumentChange may be 'added', 'removed', or 'modified'.

EmulatorMockTokenOptions
FirestoreErrorCode

The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md

FirestoreLocalCache

Union type from all supported SDK cache layer.

ListenSource

Describe the source a query listens to.

LogLevel
MemoryGarbageCollector

Union type from all support garbage collectors for memory local cache.

NestedUpdateFields

For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, 'bar.qux': T2}). Intersect them together to make a single map containing all possible keys that are all marked as optional

OrderByDirection

The direction of a orderBy clause is specified as 'desc' or 'asc' (descending or ascending).

PartialWithFieldValue

Similar to TypeScript's Partial<T>, but allows nested fields to be omitted and FieldValues to be passed in as property values.

PersistentTabManager

A union of all available tab managers.

Primitive

Primitive types.

QueryConstraintType

Describes the different query constraints available in this SDK.

QueryFilterConstraint

QueryFilterConstraint is a helper union type that represents QueryFieldFilterConstraint and QueryCompositeFilterConstraint.

QueryNonFilterConstraint

QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraints are created by invoking orderBy, {@link (startAt:1)}, {@link (startAfter:1)}, {@link (endBefore:1)}, {@link (endAt:1)}, limit or limitToLast and can then be passed to {@link (query:1)} to create a new query instance that also contains the QueryConstraint.

SetOptions

An options object that configures the behavior of {@link @firebase/firestore/lite#(setDoc:1)}, {@link

TaskState

Represents the state of bundle loading tasks.

UnionToIntersection

Given a union type U = T1 | T2 | ..., returns an intersected type (T1 & T2 & ...).

UpdateData

Update data (for use with {@link (updateDoc:1)}) that consists of field paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values.

WhereFilterOp

Filter conditions in a where clause are specified using the strings '<', '<=', '==', '!=', '>=', '>', 'array-contains', 'in', 'array-contains-any', and 'not-in'.

WithFieldValue

Allows FieldValues to be passed in as a property value while maintaining type safety.