firebase-admin.firestore package

External API Re-exports

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

Symbol Description
BulkWriter BulkWriter type from the @google-cloud/firestore package.
AggregateField AggregateField type from the @google-cloud/firestore package.
BulkWriterOptions BulkWriterOptions type from the @google-cloud/firestore package.
BundleBuilder BundleBuilder type from the @google-cloud/firestore package.
CollectionGroup CollectionGroup type from the @google-cloud/firestore package.
CollectionReference CollectionReference type from the @google-cloud/firestore package.
DocumentChange DocumentChange type from the @google-cloud/firestore package.
DocumentData DocumentData type from the @google-cloud/firestore package.
DocumentReference DocumentReference type from the @google-cloud/firestore package.
DocumentSnapshot DocumentSnapshot type from the @google-cloud/firestore package.
FieldPath FieldPath type from the @google-cloud/firestore package.
FieldValue FieldValue type from the @google-cloud/firestore package.
Filter Filter type from the @google-cloud/firestore package.
Firestore Firestore type from the @google-cloud/firestore package.
FirestoreDataConverter FirestoreDataConverter type from the @google-cloud/firestore package.
GeoPoint GeoPoint type from the @google-cloud/firestore package.
GrpcStatus GrpcStatus type from the @google-cloud/firestore package.
Precondition Precondition type from the @google-cloud/firestore package.
Query Query type from the @google-cloud/firestore package.
QueryDocumentSnapshot QueryDocumentSnapshot type from the @google-cloud/firestore package.
QueryPartition QueryPartition type from the @google-cloud/firestore package.
QuerySnapshot QuerySnapshot type from the @google-cloud/firestore package.
ReadOptions ReadOptions type from the @google-cloud/firestore package.
SetOptions SetOptions type from the @google-cloud/firestore package.
Timestamp Timestamp type from the @google-cloud/firestore package.
Transaction Transaction type from the @google-cloud/firestore package.
WriteBatch WriteBatch type from the @google-cloud/firestore package.
WriteResult WriteResult type from the @google-cloud/firestore package.
setLogFunction setLogFunction function from the @google-cloud/firestore package.

Cloud Firestore.

Functions

Function Description
getFirestore() Gets the default Firestore service for the default app.
getFirestore(app) Gets the default Firestore service for the given app.
getFirestore(databaseId) (BETA) Gets the named Firestore service for the default app.
getFirestore(app, databaseId) (BETA) Gets the named Firestore service for the given app.
initializeFirestore(app, settings) Gets the default Firestore service for the given app, passing extra parameters to its constructor.
initializeFirestore(app, settings, databaseId) (BETA) Gets the named Firestore service for the given app, passing extra parameters to its constructor.

Interfaces

Interface Description
FirestoreSettings Settings to pass to the Firestore constructor.

getFirestore()

Gets the default Firestore service for the default app.

Signature:

export declare function getFirestore(): Firestore;

Returns:

Firestore

The default Firestore service for the default app.

Example

// Get the default Firestore service for the default app
const defaultFirestore = getFirestore();

getFirestore(app)

Gets the default Firestore service for the given app.

Signature:

export declare function getFirestore(app: App): Firestore;

Parameters

Parameter Type Description
app App which Firestore service to return.

Returns:

Firestore

The default Firestore service associated with the provided app.

Example

// Get the default Firestore service for a specific app
const otherFirestore = 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 named Firestore service for the default app.

Signature:

export declare function getFirestore(databaseId: string): Firestore;

Parameters

Parameter Type Description
databaseId string name of database to return.

Returns:

Firestore

The named Firestore service for the default app.

Example

// Get the Firestore service for a named database and default app
const otherFirestore = 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 named Firestore service for the given app.

Signature:

export declare function getFirestore(app: App, databaseId: string): Firestore;

Parameters

Parameter Type Description
app App which Firestore service to return.
databaseId string name of database to return.

Returns:

Firestore

The named Firestore service associated with the provided app.

Example

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

initializeFirestore(app, settings)

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

Signature:

export declare function initializeFirestore(app: App, settings?: FirestoreSettings): Firestore;

Parameters

Parameter Type Description
app App which Firestore service to return.
settings FirestoreSettings Settings object to be passed to the constructor.

Returns:

Firestore

The default Firestore service associated with the provided app and settings.

Example

// Get the Firestore service for a specific app, require HTTP/1.1 REST transport
const otherFirestore = 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 named Firestore service for the given app, passing extra parameters to its constructor.

Signature:

export declare function initializeFirestore(app: App, settings: FirestoreSettings, databaseId: string): Firestore;

Parameters

Parameter Type Description
app App which Firestore service to return.
settings FirestoreSettings Settings object to be passed to the constructor.
databaseId string name of database to return.

Returns:

Firestore

The named Firestore service associated with the provided app and settings.

Example

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