MethodsAdd Method | Fire Snippets Docs
Add Method
Adds a document to Firestore when a button is clicked.
add(snippetId, variables)
Description
Adds a new document to a specified Firestore collection when a button is clicked. It collects data from specified input fields and saves it to Firestore, replacing any placeholders with provided variables.
Method Signature
Parameters
- snippetId: (string) The ID of the add snippet configuration.
- variables: (Array) An array of objects containing variable names and values to replace placeholders in the Firestore path.
Returns
- Promise: Resolves with a reference to the added document (
DocumentReference
), or rejects with an error.
Usage Example
HTML Elements Required
Ensure your HTML includes the following elements with IDs matching those specified in your snippet configuration:
Was this helpful?