Is there a way to make admin changes to Firestore without triggering onUpdate Cloud Function

huangapple go评论57阅读模式
英文:

Is there a way to make admin changes to Firestore without triggering onUpdate Cloud Function

问题

我正在使用Firebase Cloud Functions。有没有办法在不触发onUpdate的情况下更改用户数据?因此,我有一个onUpdate,每当用户更改数据时都会发送给我一封电子邮件,以便我知道发生了什么。但有时我必须发布、取消发布等用户数据,这会触发云函数的电子邮件。有没有办法不触发电子邮件,比如说“如果这是管理员更改,则不发送电子邮件”。

或者,是否有更好的方法来跟踪Firestore中的用户更改?

英文:

Simple question.

I'm using Firebase Cloud Functions. Is there a way to change user data without trigger onUpdate? So i have an onUpdate that sends me an email whenever a user changes data, so that i know what's going on. But there are times when i have to publish, unpublish etc user data and this triggers cloud functions email. Is there a way to not trigger the email, like say "if this is an admin change, then don't send the email".

Or, is there a better way to track user changes to Firestore?

答案1

得分: 1

没有办法不触发电子邮件,比如说“如果这是管理员更改,则不发送电子邮件”。

在这方面没有所谓的“管理员”访问权限,也没有其他内置的方法可以避免在更新匹配文档时运行更新触发器。触发器运行时您只有文档本身的内容可用,所以您唯一的选择是检查内容并决定是否触发器不执行任何操作。这意味着您可以在同一次更新期间在文档中写入一些字段,以表示不应采取任何操作。

另请参阅:

英文:

> Is there a way to not trigger the email, like say "if this is an admin change, then don't send the email".

There is no such thing as "admin" access in this respect, and there is no other built-in way to avoid running an update trigger when a matching document is updated. The only information you have available when the trigger runs is the contents of the document itself, so your only option is to check the contents and decide from there if the trigger should do nothing. This means you could possibly write some field in the document during the same update to signal that no action should be taken.

See also:

huangapple
  • 本文由 发表于 2023年7月7日 07:35:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76633102.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定