I need to know the simplest way to test if some data path actually exists in a realtime database, inside a cloud function.
Here something I tried, but I already know it is wrong:
....
admin.initializeApp();
....
exports.listAllUsers = onRequest({cors: [corsAllow]}, (req, res) => {
....
const refStr = "MyDBRoot/SectionTwo/SubSectionOne/"+userRecord.uid;
// Test code:
if (admin.database().ref(refStr) === undefined) return;
....
});
The existence of the string I build (i.e. refStr) is not the same as the path (refStr) actually existing in the DB and this last point is what I want to test.
Any hint will be more that welcome.