0

我是 Firebase 云功能的新手。我想在 index.js 中有一个函数在创建数据库中的节点时触发 - 1. 它将获取上下文的参数 2. 并找到一个节点的值,3. 从另一个数据库中获取值,4 . 将该值添加到 3 个差异位置。

exports.runningNumber = functions.database.ref("Main/Enemy/{enem_Id}/{event_Id}"}
.onCreate((snapshot, context) => {

var enemid = context.params.enem_Id;
var eventid = context.params.event_Id;

return admin.database().ref("Main/Enemy/" + enemid + "/SequenceNumber").once('value', (snapshot) => {

var newSeqNum = snapshot.val() + 1;

//then, get var userid through database().ref("Main/Enemy/" + enemid + "/" + eventid + "/user_Id")

//and then, use newSeqNum to:

//1. Replacing "Main/Enemy/" + enemid + "/SequenceNumber"

//2. Adding as string into "Main/Enemy/" + enemid + "/" + eventid + "/SeqNum"

//3. Adding as string into "Main/Users/" + userid + "/" + eventid + "/SeqNum"
});

});

希望有人可以帮助解决如何做到这一点......

4

0 回答 0