How do I check if a name exists using Cloud Functions for Firebase?
I have the following data structure:
And this pseudo-code:
exports.addIt = functions.database.ref('/messages/{pushId}')
.onWrite(event => {
if(creationDate does not exist)
event.data.adminRef.update({"creationDate":Date.now()})
else // do not update anything
})
I want to check if 'creationDate' already exists or not. How do I achieve that?
Something like this :-
exports.addIt = functions.database.ref('/messages/{pushId}')
.onWrite(event => {
if(typeof event.data.val().creationDate != 'undefined')
return event.data.adminRef.update({"creationDate":Date.now()})
else // do not update anything
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.