[英]Having trouble querying some data from the firestore
I have a Security role in fireStore like this我在这样的 fireStore 中有一个安全角色
allow read: if resource.data.uid == request.auth.uid;
and I am trying to git the data like this我正在尝试 git 这样的数据
export function GetPatients(limit) {
return async (dispatch) => {
await firebase
.firestore()
.collection("patients")
.doc(firebase.auth().currentUser.uid)
.collection("patient")
.orderBy("creation", "desc")
.where("uid", "==", firebase.auth().currentUser.uid && "importent" ,"==" ,true)
.limit(limit)
.onSnapshot((result) => {
let Patients = result.docs.map((doc) => {
const data = doc.data();
const id = doc.id;
return { id, ...data };
});
lastPatient = result.docs[result.docs.length - 1];
dispatch({ type: GET_PATIENTS, Patients });
});
};
}
do I need to change the roles or there is something wrong with how a querying the data?我需要更改角色还是查询数据的方式有问题?
the error I am getting is我得到的错误是
Error in snapshot listener: FirebaseError: Missing or insufficient permissions.
快照侦听器中的错误:FirebaseError:缺少权限或权限不足。 –
–
This is not how you add multiple conditions to a query:这不是向查询添加多个条件的方式:
.where("uid", "==", firebase.auth().currentUser.uid && "importent" ,"==" ,true)
Instead, call where
once for each condition.相反,为每个条件调用一次
where
。 So:所以:
.where("uid", "==", firebase.auth().currentUser.uid)
.where("importent" ,"==" ,true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.