简体   繁体   English

使用Cloud Functions for Firebase检查名称是否存在

[英]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.

相关问题 Firebase的云功能-如何检查孩子是否存在? - Cloud Functions for Firebase - How to check whether a child exists? Firebase 云函数:使用 onCreate() 方法时如何命名参数? - Firebase Cloud Functions: What to name parameters when using onCreate() method? 如何使用Firebase功能检查Firebase实时数据库中是否存在值? - How do you check if value exists within Firebase live database using Firebase Functions? 如何检查名称是否已存在于 Firebase 实时数据库(Firebase 和 JS)中 - How to check if name already exists in Firebase Realtime Database (Firebase & JS) 有没有办法检查 Firebase 云 function (JavaScript) 中是否存在文件夹? - Is there a way to check if a folder exists in a Firebase cloud function (JavaScript)? 使用 Ionic 检查 firebase 中是否存在数据 - Check if data exists in firebase using Ionic 如何使用angularfire检查firebase中是否存在数据? - How to check if data exists in firebase using angularfire? 使用 Firebase Cloud Functions 时未定义 httpsCallable - httpsCallable is not defined when using Firebase Cloud Functions 使用Firebase云功能侦听后台的更改 - Using firebase cloud functions to listen for changes in the background 使用 Firebase 云功能有条件地发送通知? - Send notifications conditionally using Firebase cloud functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM