如何使用firebase功能而不是管理员在数据库中写入 [英] How to write in db with firebase function not as admin
问题描述
当一些 http 触发时,我正在尝试在 firebase 函数上写入一些数据到 DB,我的问题我没有找到任何示例,因为我仍然希望采用 firebase 规则,所以没有管理员许可怎么办...
I am trying to write on firebase function some data to DB when some http triggers ,my issue I didn't find any examples how is it possible to do without admin permission because I still want firebase rules to be taken...
推荐答案
您正在寻找 event.data.ref
.来自参考文档:
返回一个参考
到发生触发写入的数据库位置.此 Reference
与执行写入的客户端具有相同的最终用户权限.因此,如果一个未经身份验证的客户端进行了写入,则此 Reference
是未经身份验证的.如果执行写入的客户端被验证为某个 Firebase Auth 用户,则此 Reference
被验证为同一用户.
Returns a
Reference
to the Database location where the triggering write occurred. ThisReference
has the same end-user permissions as the client that did the write. So, if an unauthenticated client did the write, thisReference
is unauthenticated. If the client that did the write is authenticated as a certain Firebase Auth user, thisReference
is authenticated as that same user.
这篇关于如何使用firebase功能而不是管理员在数据库中写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!