繁体   English   中英

如何在 onUpdate 函数中访问 Firestore 数据

[英]How to access firestore data in functions onUpdate

我的数据:

在此处输入图片说明

我的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);

所以我想访问users集合,但我得到:

TypeError: change.after.ref.parent is not a function

我猜您需要在用户之前使用 / ,如下所示。

.document('/users/{userId}')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM