firestore.DocumentBuilder class
Stay organized with collections
Save and categorize content based on your preferences.
Signature:
export declare class DocumentBuilder<Path extends string>
Constructors
Methods
firestore.DocumentBuilder.(constructor)
Constructs a new instance of the DocumentBuilder
class
Signature:
constructor(triggerResource: () => string, options: DeploymentOptions);
Parameters
firestore.DocumentBuilder.onCreate()
Respond only to document creations.
Signature:
onCreate(handler: (snapshot: QueryDocumentSnapshot, context: EventContext<ParamsOf<Path>>) => PromiseLike<any> | any): CloudFunction<QueryDocumentSnapshot>;
Parameters
Returns:
CloudFunction<QueryDocumentSnapshot>
firestore.DocumentBuilder.onDelete()
Respond only to document deletions.
Signature:
onDelete(handler: (snapshot: QueryDocumentSnapshot, context: EventContext<ParamsOf<Path>>) => PromiseLike<any> | any): CloudFunction<QueryDocumentSnapshot>;
Parameters
Returns:
CloudFunction<QueryDocumentSnapshot>
firestore.DocumentBuilder.onUpdate()
Respond only to document updates.
Signature:
onUpdate(handler: (change: Change<QueryDocumentSnapshot>, context: EventContext<ParamsOf<Path>>) => PromiseLike<any> | any): CloudFunction<Change<QueryDocumentSnapshot>>;
Parameters
Returns:
CloudFunction<Change<QueryDocumentSnapshot>>
firestore.DocumentBuilder.onWrite()
Respond to all document writes (creates, updates, or deletes).
Signature:
onWrite(handler: (change: Change<DocumentSnapshot>, context: EventContext<ParamsOf<Path>>) => PromiseLike<any> | any): CloudFunction<Change<DocumentSnapshot>>;
Parameters
Returns:
CloudFunction<Change<DocumentSnapshot>>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-04-24 UTC.
[null,null,["Last updated 2023-04-24 UTC."],[],[],null,["# firestore.DocumentBuilder class\n\n**Signature:** \n\n export declare class DocumentBuilder\u003cPath extends string\u003e \n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|----------------------------------------------------------------------------------------------------------------------------------|-----------|----------------------------------------------------------|\n| [(constructor)(triggerResource, options)](./firebase-functions.firestore.documentbuilder.md#firestoredocumentbuilderconstructor) | | Constructs a new instance of the `DocumentBuilder` class |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|---------------------------------------------------------------------------------------------------------|-----------|----------------------------------------------------------------|\n| [onCreate(handler)](./firebase-functions.firestore.documentbuilder.md#firestoredocumentbuilderoncreate) | | Respond only to document creations. |\n| [onDelete(handler)](./firebase-functions.firestore.documentbuilder.md#firestoredocumentbuilderondelete) | | Respond only to document deletions. |\n| [onUpdate(handler)](./firebase-functions.firestore.documentbuilder.md#firestoredocumentbuilderonupdate) | | Respond only to document updates. |\n| [onWrite(handler)](./firebase-functions.firestore.documentbuilder.md#firestoredocumentbuilderonwrite) | | Respond to all document writes (creates, updates, or deletes). |\n\nfirestore.DocumentBuilder.(constructor)\n---------------------------------------\n\nConstructs a new instance of the `DocumentBuilder` class\n\n**Signature:** \n\n constructor(triggerResource: () =\u003e string, options: DeploymentOptions);\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------------|--------------------------------------------------------------------------------------------|-------------|\n| triggerResource | () =\\\u003e string | |\n| options | [DeploymentOptions](./firebase-functions.deploymentoptions.md#deploymentoptions_interface) | |\n\nfirestore.DocumentBuilder.onCreate()\n------------------------------------\n\nRespond only to document creations.\n\n**Signature:** \n\n onCreate(handler: (snapshot: QueryDocumentSnapshot, context: EventContext\u003cParamsOf\u003cPath\u003e\u003e) =\u003e PromiseLike\u003cany\u003e | any): CloudFunction\u003cQueryDocumentSnapshot\u003e;\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| handler | (snapshot: [QueryDocumentSnapshot](./firebase-functions.firestore.md#firestorequerydocumentsnapshot), context: [EventContext](./firebase-functions.eventcontext.md#eventcontext_interface)\\\u003cParamsOf\\\u003cPath\\\u003e\\\u003e) =\\\u003e PromiseLike\\\u003cany\\\u003e \\| any | |\n\n**Returns:**\n\n[CloudFunction](./firebase-functions.cloudfunction.md#cloudfunction_interface)\\\u003c[QueryDocumentSnapshot](./firebase-functions.firestore.md#firestorequerydocumentsnapshot)\\\u003e\n\nfirestore.DocumentBuilder.onDelete()\n------------------------------------\n\nRespond only to document deletions.\n\n**Signature:** \n\n onDelete(handler: (snapshot: QueryDocumentSnapshot, context: EventContext\u003cParamsOf\u003cPath\u003e\u003e) =\u003e PromiseLike\u003cany\u003e | any): CloudFunction\u003cQueryDocumentSnapshot\u003e;\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| handler | (snapshot: [QueryDocumentSnapshot](./firebase-functions.firestore.md#firestorequerydocumentsnapshot), context: [EventContext](./firebase-functions.eventcontext.md#eventcontext_interface)\\\u003cParamsOf\\\u003cPath\\\u003e\\\u003e) =\\\u003e PromiseLike\\\u003cany\\\u003e \\| any | |\n\n**Returns:**\n\n[CloudFunction](./firebase-functions.cloudfunction.md#cloudfunction_interface)\\\u003c[QueryDocumentSnapshot](./firebase-functions.firestore.md#firestorequerydocumentsnapshot)\\\u003e\n\nfirestore.DocumentBuilder.onUpdate()\n------------------------------------\n\nRespond only to document updates.\n\n**Signature:** \n\n onUpdate(handler: (change: Change\u003cQueryDocumentSnapshot\u003e, context: EventContext\u003cParamsOf\u003cPath\u003e\u003e) =\u003e PromiseLike\u003cany\u003e | any): CloudFunction\u003cChange\u003cQueryDocumentSnapshot\u003e\u003e;\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| handler | (change: [Change](./firebase-functions.change.md#change_class)\\\u003c[QueryDocumentSnapshot](./firebase-functions.firestore.md#firestorequerydocumentsnapshot)\\\u003e, context: [EventContext](./firebase-functions.eventcontext.md#eventcontext_interface)\\\u003cParamsOf\\\u003cPath\\\u003e\\\u003e) =\\\u003e PromiseLike\\\u003cany\\\u003e \\| any | |\n\n**Returns:**\n\n[CloudFunction](./firebase-functions.cloudfunction.md#cloudfunction_interface)\\\u003c[Change](./firebase-functions.change.md#change_class)\\\u003c[QueryDocumentSnapshot](./firebase-functions.firestore.md#firestorequerydocumentsnapshot)\\\u003e\\\u003e\n\nfirestore.DocumentBuilder.onWrite()\n-----------------------------------\n\nRespond to all document writes (creates, updates, or deletes).\n\n**Signature:** \n\n onWrite(handler: (change: Change\u003cDocumentSnapshot\u003e, context: EventContext\u003cParamsOf\u003cPath\u003e\u003e) =\u003e PromiseLike\u003cany\u003e | any): CloudFunction\u003cChange\u003cDocumentSnapshot\u003e\u003e;\n\n### Parameters\n\n| Parameter | Type | Description |\n|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| handler | (change: [Change](./firebase-functions.change.md#change_class)\\\u003c[DocumentSnapshot](./firebase-functions.firestore.md#firestoredocumentsnapshot)\\\u003e, context: [EventContext](./firebase-functions.eventcontext.md#eventcontext_interface)\\\u003cParamsOf\\\u003cPath\\\u003e\\\u003e) =\\\u003e PromiseLike\\\u003cany\\\u003e \\| any | |\n\n**Returns:**\n\n[CloudFunction](./firebase-functions.cloudfunction.md#cloudfunction_interface)\\\u003c[Change](./firebase-functions.change.md#change_class)\\\u003c[DocumentSnapshot](./firebase-functions.firestore.md#firestoredocumentsnapshot)\\\u003e\\\u003e"]]