【发布时间】:2020-07-06 23:49:59
【问题描述】:
我正在尝试从由 childByAutoId() 保存的 firebase 中读取数据。我可以成功读取上半部分,但读取的是 childByAutoId() 是什么。例如。
在我的 firebase 函数中是
记录器 -- uid is BoSwank... 是正确的,但是在下面的行中
logger -- workerId 是 -MBauxL.... 不正确。这是 childByAutoID() 的值,应该是 hkKplzF...
下面是我如何尝试读取这些数据。
exports.observeNotifications = functions.database.ref('/notifications/{cardUID}/{workerId}').onCreate((snapshot, context) => {
var uid = context.params.cardUID;
var workerId = context.params.workerId;
console.log('LOGGER --- uid is ' + uid);
console.log('LOGGER --- workerId is ' + workerId)
})
我想改变 /notifications/{cardUID}/{workerId} 到 /notifications/{cardUID}/{cardUID/workerId}
然后改变
var workerId = context.params.workerId;
到
var workerId = context.params.cardUID.workerId;
会做的伎俩,但它没有。
【问题讨论】:
标签: javascript node.js firebase-realtime-database google-cloud-functions