I am trying to query a subset of a collection from firestore. My firestore rules for the route are
match /data/{firstId}/subCol/{secondId}/subSubCol/{thirdId} {
allow create: if true;
allow read: if resource.data.authorUid == request.auth.uid;
allow write: if resource.data.authorUid == request.auth.uid;
allow delete: if resource.data.authorUid == request.auth.uid;
}
I can write to the document at this location perfectly fine. However, whenever I attempt to a frontend query like this:
const getAllDocsFromCollection(firstId, secondId) {
const auth = getAuth();
const userId = auth?.currentUser?.uid
if(!userId) {
throw new Error("UserId undefined")
}
const colQuery = query(collection(db, "data", firstId, "subCol", secondId, "subSubCol"), where("authorUid", "==", userId));
const docs = await getDocs(colQuery);
return docs;
}
I receive the error: FirebaseError: Missing or insufficient permissions.
All of the identifying information is correct, and when I attempt to write to an individual document from the frontend it works fine. There is only an issue when I pull the collection. I know that when attempting to get all docs from a firestore collection, if a rule fails on any single doc, the entire query fails, however, in this instance, I believe am using a frontend query that should filter the collection and only pull docs the user has access to.