【发布时间】:2017-07-01 06:13:27
【问题描述】:
我的 firebase-database 结构如下:
还有我在node.js中的函数代码:
exports.addFunction = functions.database
.ref('/Users/{uid}/GyroScope X-axis')
.onWrite(event => {
var add = 0;
const addGyroX = admin.database().ref('/GyroXaddition');
const userRef = event.data.adminRef;
userRef.once('value').then(snapshot => {
snapshot.forEach(childrensnap => {
var reading = childrensnap.key;
var childData = reading.val();
add = add+childData;
return addGyroX.set(childData);
});
});
});
我的计划是迭代 GyroScope X 轴的值,并在迭代时将值更新为新创建的路径 (GyroXaddition)。我没有收到任何错误,但它也没有更新。
【问题讨论】:
标签: node.js firebase firebase-realtime-database google-cloud-functions