Im trying to switch from Firebase first gen to 2nd gen, and it already frustrated me,
this is just my code, simple
const {onDocumentCreated} = require("firebase-functions/v2/firestore");
exports.totalGroup = onDocumentCreated(
{region: "asia-southeast2"}, "tallyscan/{id}", async (event)=>{
console.log("get event data");
const snapshot = event.data();
const id = event.params.id;
console.log(snapshot);
console.log(id);
});
This the error
TypeError: Cannot read properties of undefined (reading ‘value’)
at func (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:297:115)
at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:113:25
at process.processTicksAndRejections (node:internal/process/task_queues:95:5
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
},
"main": "index.js",
"dependencies": {
"exceljs": "^4.4.0",
"firebase-admin": "^12.1.0",
"firebase-functions": "^5.0.1"
},
"devDependencies": {
"eslint": "^8.15.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^3.1.0"
},
"private": true
}