【发布时间】:2020-04-17 08:06:06
【问题描述】:
我的事件文档中有一个名为title 的字段,其中包含一个布尔值。我在我的文档中设置了 onUpdate firestore 触发器。我想如果我的title 更新了,那么我会采取一些行动。但如果其他字段被更新,那么我根本不会执行任何操作。该怎么做?
如果每次文档有更新时都调用下面的函数,我没问题,但我只想在 title 更新时做一些进一步的操作
exports.dbEventsOnUpdate = functions.firestore
.document('events/{eventId}').onUpdate(async (change,context) => {
try {
const eventID = context.params.eventId
if (titleIsUpdated) {
return db.doc(``).set(newData)
} else {
// do nothing here
return null
}
} catch(error) {
console.log(error)
return null
}
})
【问题讨论】:
标签: firebase google-cloud-firestore google-cloud-functions