gpt4 book ai didi

javascript - 使用 firebase 函数检查数据是否存在

转载 作者:行者123 更新时间:2023-12-01 00:26:04 25 4
gpt4 key购买 nike

如何检查 days节点是否存在使用 Firebase Cloud Function?
index.js 内的伪代码:

if(days.exists())
{
//do something
}

see data structure here

最佳答案

// 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
}
});

关于javascript - 使用 firebase 函数检查数据是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44849927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com