How can I write these functions such that there work with v2.
const {onSchedule} = require("firebase-functions/v2/scheduler");
const {logger} = require("firebase-functions");
const {functions} = require("firebase-functions");
// The Firebase Admin SDK to access Firestore.
const {initializeApp} = require("firebase-admin/app");
const firebaseTools = require("firebase-tools");
initializeApp();
async function deletePath(path) {
await firebaseTools.firestore
.delete(path, {
project: process.env.GCLOUD_PROJECT,
recursive: true,
force: true,
token: functions.config().fb.token,
});
}
The cloud console is giving me this error:
Error: functions.config() is no longer available in Cloud Functions for Firebase v2. Please see the latest documentation for information on how to transition to using environment variables
I have checked the documentation. There are some examples with onDocumentCreated. I could figure out how that could help me.
As mentioned by @Doug Stevenson:
Then
Use
firebase deploy --only functionsto deploy v2 functions.Reference:
Configure your environment
V2 and examples: Extend Cloud Firestore with Cloud Functions (2nd gen)