我正在使用 Firestore。它需要安全规则。
以下是我针对集合组运行的实际查询:
const db = getFirestore(app);
const MainCollection = collectionGroup(db, "list");
const searchQuery = query(
MainCollection,
where("destination", "==", itinerary.destination),
);
收集路径为
/maincollection/{userId}/list/{documents=**}
。
CoPilot 建议的 Firebase 规则:
match /maincollection/{userId} {
allow read: if request.auth != null;
match /list/{document=**} {
allow read: if request.auth != null;
}
}
match /maincollection/{doc}/list/{itin} {
allow read: if request.auth != null;
}
match /maincollection/{doc}/list/{document=**} {
allow read: if request.auth != null;
}
match /maincollection/{document=**} {
allow read, write: if request.auth != null;
}
所有这些都给我以下错误:
搜索行程时出错:FirebaseError:缺少或权限不足。