[英]Check if name exists using Cloud Functions for Firebase
How do I check if a name exists using Cloud Functions for Firebase? 如何使用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. 我想检查'creationDate'是否已经存在。 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
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.