Type "firestoreDocumentPath"

Frequently you may find yourself writing a function that reads or writes into the Firestore database document. The same solution (the function code) could be used in the same project or in others, but reading or writing into different paths. For example, a function that syncs a Firestore collection with a BigQuery table could be used multiple times to synchronize different Firestore collections.

If you are writing a function that requires a document path in the Firestore database, either because you want to read or write to that document, you can use environment variables of type firestoreDocumentPath in your implementation, and then our platform will ask consumers to enter its value during installation.‌‌

The variables type firestoreDocumentPath allow the consumers of a function to enter any firestore document path valid. It is presented in the installation UI form as an input element (see image below).

Example of an environment variable type "firestoreDocumentPath" definition

"env": [
    {
        "name": "NOTIFICATIONS_COUNTER_DOCUMENT_PATH",
        "description": "The path to the document that will track the notifications count.",
        "required": true,
        "type": "firestoreDocumentPath",
        "default": "/users/notifications"
    }
]

Example of how to consume the value of the environment variable within the function implementation

const myFunction = () => {
    const notificationsDocumentPath = process.env.NOTIFICATIONS_COUNTER_DOCUMENT_PATH
    ...
};

module.exports = myFunction;

Properties of the type

property

type

required

default

description

name

string

yes

-

The name of the environment variable. This should be unique for each variable.

description

string

no

-

The description of the environment variable.

default

string

no

-

The default value for the variable.

required

bool

no

false

Specifies that must fill out the variable before submitting.

Last updated