Firestore规则 - 我做错了什么?

时间:2018-04-09 03:17:32

标签: google-cloud-firestore

我正在开发一款应用程序,将Caretakers(用户)与其子女通过家庭联系起来。 Family数据结构如下:

/families/idFAMILY {
  id: 'idFAMILY',
  name: "Smith',
  caretakers: {
    idPARENT1: "true",
    idPARENT2: "true"
  },
  children: {
    idCHILD1: "true",
    idCHILD2: "true"
  }
}

(以id开头的所有内容都是自动生成的ID)

使用Angularfire,我尝试使用此查询获取当前用户的系列列表:

const path = 'caretakers.' + userId;
const famCollection = this.afs.collection('families', ref => ref.where(path, '==', 'true')).valueChanges()

但是我得到了#34;缺少权限或权限不足"错误,我无法弄清楚原因。

我的规则是:

function isCaretaker(familyId, userId) {
  return get(/databases/$(database)/documents/families/$(familyId)).data.caretakers[userId] == 'true';
}
match /families/{familyId} {
  allow create: if userExists();
  allow read, write: if isCaretaker(familyId, request.auth.uid);
}

任何人都可以帮我弄清楚我做错了什么吗?提前谢谢。

0 个答案:

没有答案
相关问题