在Firestore安全规则中,可以在另一个自定义功能中使用自定义功能吗?
在Firestore安全规则中,我正在编写一个自定义函数(IseEtherNotSecreTorIsowner()
),其中还有另一个自定义函数(allystorequestor()
),但是官方的Google Firebase文档在自定义功能上似乎是沉默的好的。
代码摘录以下:
function belongsToRequestor() {
return request.auth.uid == resource.data.userId
}
function isEitherNotSecretOrIsOwner() {
resource.data.reviewPrivacy != 'keepSecret' ||
belongsToRequestor()
}
我希望这没关系,因为我需要将iSeEthernOtseCretorIsowner()
放入一组更长的&&&
条件中,而我是我的条件不确定如何在&&
条件的字符串中拥有“ x || y”。
感谢您的任何帮助!
In Firestore security rules, I'm writing a custom function (isEitherNotSecretOrIsOwner()
), with another custom function (belongsToRequestor()
) inside of it, but the official Google Firebase documentation on custom functions seems to be silent on whether this is okay or not.
Code excerpt below:
function belongsToRequestor() {
return request.auth.uid == resource.data.userId
}
function isEitherNotSecretOrIsOwner() {
resource.data.reviewPrivacy != 'keepSecret' ||
belongsToRequestor()
}
I hope this is okay, because I need to put the isEitherNotSecretOrIsOwner()
inside a longer set of &&
conditions and I'm not sure how else to have the "either X || Y" inside a string of &&
conditions…
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要您所调用的功能在呼叫站点的范围中,就确实支持了来自另一个自定义功能的一个自定义功能。
Calling one custom functions from within another one is indeed supported in Firestore security rules, as long as the function you're calling is in scope at the call site.