如何使用Firebase云功能检查days
节点是否存在?
index.js
内的伪代码:
if(days.exists())
{
//do something
}
答案 0 :(得分:3)
// outside of function body
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
// inside function body
return admin.database().ref('days').once('value').then(snap => {
if (snap.exists()) {
// do something
}
});