Firestore安全规则 - 查询集合时检查文档字段

时间:2018-06-16 22:51:23

标签: javascript google-cloud-firestore firebase-security-rules

在查询文档集合并使用安全规则检查文档上的字段以允许读取时,我得到:

"Uncaught Error in onSnapshot: Error: Missing or insufficient permissions."

我的查询:

firebase.firestore().collection('photos').where('event', '==', eventId).orderBy('uploadedAt', "desc").limit(11)
.onSnapshot((photoBatch) => {
  let photos = []
  photoBatch.docs.forEach(doc => {
    let photo = doc.data()
    photo.id = doc.id
    photos.push(photo) 
  });
  return = photos
})

我的规则:

match /databases/{database}/documents {
  match /photos/{photo} {
    allow read: if resource.data.privatePhoto == false
  }
}

此查询返回的所有文档都有字段

privatePhoto: false

是否存在关于返回多个文档以阻止检查单个文档字段的内容?

0 个答案:

没有答案