【发布时间】:2020-08-14 14:05:04
【问题描述】:
我有一个来自 Firebase 的实时数据库,其中数据存储在单个字符串中,而不是对象中。问题是 foreach 循环最后执行,因为它需要首先运行(我的意思是顺序)。它从循环中出来而不执行它的工作。
exports.room_server = functions.database.ref(`/${Role.ROOM_REQUEST}/{room}`)
.onCreate((snapshot,context)=>{
// her ref.once is refrence to another node of database
ref.limttolast(3).once("value",function(snap){
snap.forEach(function (usr) {
adm = usr.val();
console.log("admin " + adm);
});
}).catch();
console.log(" cl " + adm);
});
// cl undefined is shown first
// then it comes
// admin abc
// admin you
// admin me
//result should be
//admin abc
//admin you
//admin me
//cl me
【问题讨论】:
标签: javascript typescript firebase firebase-realtime-database google-cloud-functions