如何迭代 Firebase 安全规则语言中的列表?
How to iterate a list in Firebase Security Rules language?
我在 Firebase 存储规则中写入了以下条件:
allow read: if resource.metadata.company.includes(request.auth.uid);
此returns以下错误:
Error running simulation – Error: simulator.rules line [9], column [22]. Function not found error: Name: [includes].
我想做的是遍历一个列表并检查该列表中是否存在一个对象;类似于 includes()
的东西。如何在 Firebase 安全规则语言中做到这一点?
注意: 已经尝试了循环,但它们不起作用。
使用 string.matches('.*'+resource.metadata.company+'.*')
找到了解决方案。为什么我使用 matches
?那是因为我的数组是一个 JSON 字符串。希望这对其他人有帮助。
检查文档:https://firebase.google.com/docs/reference/rules/rules.String#matches
我在 Firebase 存储规则中写入了以下条件:
allow read: if resource.metadata.company.includes(request.auth.uid);
此returns以下错误:
Error running simulation – Error: simulator.rules line [9], column [22]. Function not found error: Name: [includes].
我想做的是遍历一个列表并检查该列表中是否存在一个对象;类似于 includes()
的东西。如何在 Firebase 安全规则语言中做到这一点?
注意: 已经尝试了循环,但它们不起作用。
使用 string.matches('.*'+resource.metadata.company+'.*')
找到了解决方案。为什么我使用 matches
?那是因为我的数组是一个 JSON 字符串。希望这对其他人有帮助。
检查文档:https://firebase.google.com/docs/reference/rules/rules.String#matches