【发布时间】:2021-03-08 22:29:02
【问题描述】:
我设置的规则是允许读取:if resource.data.uid == request.auth.uid;
我怎么称呼它是这样的
return async (dispatch) => {
await firebase
.firestore()
.collection("patients")
.doc(firebase.auth().currentUser.uid)
.collection("patient")
.orderBy("creation", "desc")
.get()
.then((result) => {
let Patients = result.docs.map((doc) => {
const data = doc.data();
const id = doc.id;
return { id, ...data };
});
dispatch({ type: GET_PATIENTS, Patients });
});
};
我该如何解决?
firebase 规则
match /databases/{database}/documents {
match /patients/{patientsID}{
match /patient/{patientID}{
allow read: if resource.data.uid == request.auth.uid;
allow create: if request.resource.data.uid == request.auth.uid;
allow update: if request.resource.data.uid == request.auth.uid;
allow delete: if resource.data.uid == request.auth.uid;
match /diagnostic/{diagnosticID}{
allow read: if true;
allow write: if request.resource.data.uid == request.auth.uid;
}
}
}
}
}
数据图像
【问题讨论】:
-
我试图在下面提供帮助。如果不是这样,您能否编辑您的问题(下面有一个链接)以包括:1)重现此问题的最小、完整规则(因为检查可能出现在许多地方),2)截图您希望通过此查询返回的文档。
-
我明天试试,现在已经晚了,谢谢你的帮助
-
没有用,我会用你的要求添加问题
-
在我将索引添加到 Firebase 后,它现在可以工作了,谢谢
标签: javascript firebase react-native google-cloud-firestore