firebase-admin.firestore package

External API Re-exports

The following externally defined APIs are re-exported from this module entry point for convenience.

SymbolDescription
BulkWriterBulkWriter type from the@google-cloud/firestore package.
AggregateFieldAggregateField type from the@google-cloud/firestore package.
BulkWriterOptionsBulkWriterOptions type from the@google-cloud/firestore package.
BundleBuilderBundleBuilder type from the@google-cloud/firestore package.
CollectionGroupCollectionGroup type from the@google-cloud/firestore package.
CollectionReferenceCollectionReference type from the@google-cloud/firestore package.
DocumentChangeDocumentChange type from the@google-cloud/firestore package.
DocumentDataDocumentData type from the@google-cloud/firestore package.
DocumentReferenceDocumentReference type from the@google-cloud/firestore package.
DocumentSnapshotDocumentSnapshot type from the@google-cloud/firestore package.
FieldPathFieldPath type from the@google-cloud/firestore package.
FieldValueFieldValue type from the@google-cloud/firestore package.
FilterFilter type from the@google-cloud/firestore package.
FirestoreFirestore type from the@google-cloud/firestore package.
FirestoreDataConverterFirestoreDataConverter type from the@google-cloud/firestore package.
GeoPointGeoPoint type from the@google-cloud/firestore package.
GrpcStatusGrpcStatus type from the@google-cloud/firestore package.
PreconditionPrecondition type from the@google-cloud/firestore package.
QueryQuery type from the@google-cloud/firestore package.
QueryDocumentSnapshotQueryDocumentSnapshot type from the@google-cloud/firestore package.
QueryPartitionQueryPartition type from the@google-cloud/firestore package.
QuerySnapshotQuerySnapshot type from the@google-cloud/firestore package.
ReadOptionsReadOptions type from the@google-cloud/firestore package.
SetOptionsSetOptions type from the@google-cloud/firestore package.
TimestampTimestamp type from the@google-cloud/firestore package.
TransactionTransaction type from the@google-cloud/firestore package.
WriteBatchWriteBatch type from the@google-cloud/firestore package.
WriteResultWriteResult type from the@google-cloud/firestore package.
setLogFunctionsetLogFunction function from the@google-cloud/firestore package.

Cloud Firestore.

Functions

FunctionDescription
getFirestore()Gets the defaultFirestore service for the default app.
getFirestore(app)Gets the defaultFirestore service for the given app.
getFirestore(databaseId)(BETA) Gets the namedFirestore service for the default app.
getFirestore(app, databaseId)(BETA) Gets the namedFirestore service for the given app.
initializeFirestore(app, settings)Gets the defaultFirestore service for the given app, passing extra parameters to its constructor.
initializeFirestore(app, settings, databaseId)(BETA) Gets the namedFirestore service for the given app, passing extra parameters to its constructor.

Classes

ClassDescription
FirebaseFirestoreErrorFirebase Firestore error code structure. This extends FirebaseError.

Interfaces

InterfaceDescription
FirestoreSettingsSettings to pass to the Firestore constructor.

getFirestore()

Gets the defaultFirestore service for the default app.

Signature:

exportdeclarefunctiongetFirestore():Firestore;

Returns:

Firestore

The defaultFirestore service for the default app.

Example

// Get the default Firestore service for the default appconstdefaultFirestore=getFirestore();

getFirestore(app)

Gets the defaultFirestore service for the given app.

Signature:

exportdeclarefunctiongetFirestore(app:App):Firestore;

Parameters

ParameterTypeDescription
appAppwhichFirestore service to return.

Returns:

Firestore

The defaultFirestore service associated with the provided app.

Example

// Get the default Firestore service for a specific appconstotherFirestore=getFirestore(app);

getFirestore(databaseId)

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the namedFirestore service for the default app.

Signature:

exportdeclarefunctiongetFirestore(databaseId:string):Firestore;

Parameters

ParameterTypeDescription
databaseIdstringname of database to return.

Returns:

Firestore

The namedFirestore service for the default app.

Example

// Get the Firestore service for a named database and default appconstotherFirestore=getFirestore('otherDb');

getFirestore(app, databaseId)

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the namedFirestore service for the given app.

Signature:

exportdeclarefunctiongetFirestore(app:App,databaseId:string):Firestore;

Parameters

ParameterTypeDescription
appAppwhichFirestore service to return.
databaseIdstringname of database to return.

Returns:

Firestore

The namedFirestore service associated with the provided app.

Example

// Get the Firestore service for a named database and specific app.constotherFirestore=getFirestore('otherDb');

initializeFirestore(app, settings)

Gets the defaultFirestore service for the given app, passing extra parameters to its constructor.

Signature:

exportdeclarefunctioninitializeFirestore(app:App,settings?:FirestoreSettings):Firestore;

Parameters

ParameterTypeDescription
appAppwhichFirestore service to return.
settingsFirestoreSettingsSettings object to be passed to the constructor.

Returns:

Firestore

The defaultFirestore service associated with the provided app and settings.

Example

// Get the Firestore service for a specific app, require HTTP/1.1 REST transportconstotherFirestore=initializeFirestore(app,{preferRest:true});

initializeFirestore(app, settings, databaseId)

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the namedFirestore service for the given app, passing extra parameters to its constructor.

Signature:

exportdeclarefunctioninitializeFirestore(app:App,settings:FirestoreSettings,databaseId:string):Firestore;

Parameters

ParameterTypeDescription
appAppwhichFirestore service to return.
settingsFirestoreSettingsSettings object to be passed to the constructor.
databaseIdstringname of database to return.

Returns:

Firestore

The namedFirestore service associated with the provided app and settings.

Example

// Get the Firestore service for a specific app, require HTTP/1.1 REST transportconstotherFirestore=initializeFirestore(app,{preferRest:true},'otherDb');

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-05-21 UTC.