firestore namespace

Functions

FunctionDescription
onDocumentCreated(document, handler)Event handler that triggers when a document is created in Firestore.
onDocumentCreated(opts, handler)Event handler that triggers when a document is created in Firestore.
onDocumentCreatedWithAuthContext(document, handler)Event handler that triggers when a document is created in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentCreatedWithAuthContext(opts, handler)Event handler that triggers when a document is created in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentDeleted(document, handler)Event handler that triggers when a document is deleted in Firestore.
onDocumentDeleted(opts, handler)Event handler that triggers when a document is deleted in Firestore.
onDocumentDeletedWithAuthContext(document, handler)Event handler that triggers when a document is deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentDeletedWithAuthContext(opts, handler)Event handler that triggers when a document is deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentUpdated(document, handler)Event handler that triggers when a document is updated in Firestore.
onDocumentUpdated(opts, handler)Event handler that triggers when a document is updated in Firestore.
onDocumentUpdatedWithAuthContext(document, handler)Event handler that triggers when a document is updated in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentUpdatedWithAuthContext(opts, handler)Event handler that triggers when a document is updated in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentWritten(document, handler)Event handler that triggers when a document is created, updated, or deleted in Firestore.
onDocumentWritten(opts, handler)Event handler that triggers when a document is created, updated, or deleted in Firestore.
onDocumentWrittenWithAuthContext(document, handler)Event handler that triggers when a document is created, updated, or deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.
onDocumentWrittenWithAuthContext(opts, handler)Event handler that triggers when a document is created, updated, or deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Classes

ClassDescription
ChangeThe Cloud Functions interface for events that change state, such as Realtime Database or Cloud FirestoreonWrite andonUpdate events.For more information about the format used to constructChange objects, see below.

Interfaces

InterfaceDescription
DocumentOptionsDocumentOptions extend EventHandlerOptions with provided document and optional database and namespace.
FirestoreAuthEvent
FirestoreEventA CloudEvent that contains a DocumentSnapshot or a Change

Type Aliases

Type AliasDescription
AuthTypeAuthType defines the possible values for the authType field in a Firestore event with auth context. - service_account: a non-user principal used to identify a workload or machine user. - api_key: a non-user client API key. - system: an obscured identity used when Cloud Platform or another system triggered the event. Examples include a database record which was deleted based on a TTL. - unauthenticated: an unauthenticated action. - unknown: a general type to capture all other principals not captured in the other auth types.
DocumentSnapshotA Firestore DocumentSnapshot
QueryDocumentSnapshotA Firestore QueryDocumentSnapshot

firestore.onDocumentCreated()

Event handler that triggers when a document is created in Firestore.

Signature:

exportdeclarefunctiononDocumentCreated<Documentextendsstring>(document:Document,handler:(event:FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create occurs.

Returns:

CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentCreated()

Event handler that triggers when a document is created in Firestore.

Signature:

exportdeclarefunctiononDocumentCreated<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create occurs.

Returns:

CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentCreatedWithAuthContext()

Event handler that triggers when a document is created in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentCreatedWithAuthContext<Documentextendsstring>(document:Document,handler:(event:FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create occurs.

Returns:

CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentCreatedWithAuthContext()

Event handler that triggers when a document is created in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentCreatedWithAuthContext<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create occurs.

Returns:

CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentDeleted()

Event handler that triggers when a document is deleted in Firestore.

Signature:

exportdeclarefunctiononDocumentDeleted<Documentextendsstring>(document:Document,handler:(event:FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore delete occurs.

Returns:

CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentDeleted()

Event handler that triggers when a document is deleted in Firestore.

Signature:

exportdeclarefunctiononDocumentDeleted<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore delete occurs.

Returns:

CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentDeletedWithAuthContext()

Event handler that triggers when a document is deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentDeletedWithAuthContext<Documentextendsstring>(document:Document,handler:(event:FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore delete occurs.

Returns:

CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentDeletedWithAuthContext()

Event handler that triggers when a document is deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentDeletedWithAuthContext<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore delete occurs.

Returns:

CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined,ParamsOf<Document>>>

firestore.onDocumentUpdated()

Event handler that triggers when a document is updated in Firestore.

Signature:

exportdeclarefunctiononDocumentUpdated<Documentextendsstring>(document:Document,handler:(event:FirestoreEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore update occurs.

Returns:

CloudFunction<FirestoreEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentUpdated()

Event handler that triggers when a document is updated in Firestore.

Signature:

exportdeclarefunctiononDocumentUpdated<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore update occurs.

Returns:

CloudFunction<FirestoreEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentUpdatedWithAuthContext()

Event handler that triggers when a document is updated in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentUpdatedWithAuthContext<Documentextendsstring>(document:Document,handler:(event:FirestoreAuthEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore update occurs.

Returns:

CloudFunction<FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentUpdatedWithAuthContext()

Event handler that triggers when a document is updated in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentUpdatedWithAuthContext<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreAuthEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<Change<QueryDocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore update occurs.

Returns:

CloudFunction<FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentWritten()

Event handler that triggers when a document is created, updated, or deleted in Firestore.

Signature:

exportdeclarefunctiononDocumentWritten<Documentextendsstring>(document:Document,handler:(event:FirestoreEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create, update, or delete occurs.

Returns:

CloudFunction<FirestoreEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentWritten()

Event handler that triggers when a document is created, updated, or deleted in Firestore.

Signature:

exportdeclarefunctiononDocumentWritten<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create, update, or delete occurs.

Returns:

CloudFunction<FirestoreEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentWrittenWithAuthContext()

Event handler that triggers when a document is created, updated, or deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentWrittenWithAuthContext<Documentextendsstring>(document:Document,handler:(event:FirestoreAuthEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
documentDocumentThe Firestore document path to trigger on.
handler(event:FirestoreAuthEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create, update, or delete occurs.

Returns:

CloudFunction<FirestoreAuthEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.onDocumentWrittenWithAuthContext()

Event handler that triggers when a document is created, updated, or deleted in Firestore. This trigger also provides the authentication context of the principal who triggered the event.

Signature:

exportdeclarefunctiononDocumentWrittenWithAuthContext<Documentextendsstring>(opts:DocumentOptions<Document>,handler:(event:FirestoreAuthEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>)=>any|Promise<any>):CloudFunction<FirestoreAuthEvent<Change<DocumentSnapshot>|undefined,ParamsOf<Document>>>;

Parameters

ParameterTypeDescription
optsDocumentOptions<Document>Options that can be set on an individual event-handling function.
handler(event:FirestoreAuthEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>) => any | Promise<any>Event handler which is run every time a Firestore create, update, or delete occurs.

Returns:

CloudFunction<FirestoreAuthEvent<Change<DocumentSnapshot> | undefined,ParamsOf<Document>>>

firestore.AuthType

AuthType defines the possible values for the authType field in a Firestore event with auth context. - service_account: a non-user principal used to identify a workload or machine user. - api_key: a non-user client API key. - system: an obscured identity used when Cloud Platform or another system triggered the event. Examples include a database record which was deleted based on a TTL. - unauthenticated: an unauthenticated action. - unknown: a general type to capture all other principals not captured in the other auth types.

Signature:

exporttypeAuthType="service_account"|"api_key"|"system"|"unauthenticated"|"unknown";

firestore.DocumentSnapshot

A Firestore DocumentSnapshot

Signature:

exporttypeDocumentSnapshot=firestore.DocumentSnapshot;

firestore.QueryDocumentSnapshot

A Firestore QueryDocumentSnapshot

Signature:

exporttypeQueryDocumentSnapshot=firestore.QueryDocumentSnapshot;

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-09-20 UTC.