【发布时间】:2017-08-17 18:15:24
【问题描述】:
每当我的程序尝试修改firebase function 中的exists 时,获得的值都是临时的。我希望能够在此function 的末尾@ 987654323@ 或false。我看过一些相关的帖子,但似乎没有任何效果。制作exists global 并分离snapshot function 不起作用。有什么建议吗?
function checkIfUserExists(userId) {
var exists;
var usersRef = firebase.database().ref("users");
usersRef.child(userId).once('value').then(function(snapshot) {
exists = (snapshot.val() !== null); // exists is true or false
userExistsCallback(userId, exists);
});
return exists; //exists is undefined
}
【问题讨论】:
标签: javascript firebase firebase-realtime-database