【发布时间】:2018-05-19 22:46:54
【问题描述】:
我正在尝试访问 firestore 文档的内容,但我一直未定义。我怀疑我错误地引用了该文档。 变量 updateId 正确打印到控制台,并且是 firebase auth id 的值,它代表 firestore db 中路径的一部分,即 users/fireauth_id。
在文档 users/fireauth_id 中,我有一个名为 token 的字段,我正在尝试返回,但 doc.data.token 始终未定义。我确实尝试使用带有 .doc({updateId}) 而不是 doc(updateId) 的路径,但没有运气。
exports.updateRequest = functions.firestore
.document('users/{userId}')
.onUpdate(event => {
var newValue = event.data.data();
var updateId = newValue.update_id;
return db.collection('users').doc(updateId).get().then(doc => {
console.log("this doesn't work: %s", doc.data.token)
谢谢。
【问题讨论】:
标签: node.js google-cloud-functions google-cloud-firestore