【发布时间】:2020-10-22 20:03:35
【问题描述】:
我正在编写一个 Firebase 云函数,它执行以下操作:
-
监听删除评论,该评论存储在“cmets”集合下,包含“time”字段,该字段存储由 admin.firestore.FieldValue.serverTimestamp() 返回的时间戳值。
-
查询另一个集合'notification',其中包含有关cmets的信息,包括'time'字段。在这里,我尝试按时间戳查询。
问题是,下面的查询不起作用。如何按时间戳查询 Firestore?正确的语法是什么?
exports.comment_deletion = functions.firestore
.document('comments/{commentid}').onDelete((snap,context)=>{
const data=snap.data();
const time=data.time; //This field is created by admin.firestore.FieldValue.serverTimestamp()
//Below query will return empty result...what will be the right syntax to use?
return db.collection('notification').where('time','==',time).get()
.then(querysnapshot=>{
querysnapshot.forEach(doc=>{
return doc.ref.delete();
})
})
})
提前非常感谢!
【问题讨论】:
标签: firebase google-cloud-firestore