Check If Data Exists Using Firebase Function
How can I check if the days node exists using Firebase Cloud Function? Pseudo-code inside index.js: if(days.exists()) { //do something }
Solution 1:
// 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
}
});
Post a Comment for "Check If Data Exists Using Firebase Function"