[英]How to access firestore data in functions onUpdate
My data:我的数据:
My firestore function:我的firestore功能:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.onMessageCreate = functions.firestore
.document('users/{userId}')
.onUpdate((change, context) => {
console.log(change.after.ref.parent);
So I want to access the users
collection, but I get:所以我想访问
users
集合,但我得到:
TypeError: change.after.ref.parent is not a function
I guess you need to use a / before users as below.我猜您需要在用户之前使用 / ,如下所示。
.document('/users/{userId}') .document('/users/{userId}')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.