Google cloud firestore 有没有办法验证firestore规则中的数组

Google cloud firestore 有没有办法验证firestore规则中的数组,google-cloud-firestore,firebase-security,Google Cloud Firestore,Firebase Security,当我在firebase控制台中看到我的数据时,它将如下所示 我正在编写firestore安全规则来保护数据 安全规则: match /wallpost/{wallpostId} { allow read: if true; allow list: if request.query.limit <= 10; allow create, update, delete: if resource.data.createdBy

当我在firebase控制台中看到我的数据时,它将如下所示

我正在编写firestore安全规则来保护数据

安全规则:

     match /wallpost/{wallpostId} {
          allow read: if true;
          allow list: if request.query.limit <= 10;
          allow create, update, delete: if resource.data.createdBy == request.auth.uid && request.resource.data.createdBy is string && request.resource.data.description is string 
// && **HERE I WANT VALIDATE TAG - WHICH IS A ARRAY OF STRING** 
        }
match/wallpost/{wallpostId}{
允许读取:如果为真;

允许列表:if request.query.limit如果
tag1
位于
tag
字段中,则允许读取文档,可以执行以下操作:

match /posts/{postID} {
  allow read: if 'tag1' in resource.data.tag
}
另见:

  • 这篇博文包含了这个方便的图表:

同样的逻辑也适用于此。如果您想在正在编写的文档中进行验证(而不是在编写之前存在的文档),请使用
request.resource
而不仅仅是
resource
。use可以像update一样进行更新({viewers:[1,2,3,NaN,null]},{merge:true})。我如何限制该用户使用firebase规则。请提出建议。因为firestore也没有for循环…如果您能举例说明,这将很有帮助…我是firestore的新手…请您确认,是否可以编写安全规则…以便我使用其他一些选项…我的答案显示了如何验证我确定存在某个标记。如果这不是您想要的,我不理解您试图验证的标记数组的内容。