I have a firestore database with a collection of products and a collection of categories.
I want give at the user the delete permission on the categories collection only if the category document not have a products field.
the products field is an array of reference.
I have this rules:
match /shops/{shopId} {
allow read: if true;
allow write: if false;
match /categories/{category=**}{
allow read: if true;
allow write: if resource.data.products == null;
}
}
But this rules not works, I cannot write or update a document.