In my app, each user has a document in the users collection of my database. Under each user's document, there is a subcollection for that user's uploaded foods. By default, I want to limit it so that the user cannot add more than 25 foods to their personal subcollection. Is there a way to check via Security Rules if the collection size is <= 25?
Asked
Active
Viewed 220 times
1 Answers
0
It's not possible in security rules.
If you want a document count, you will have to manage one of your own in a single document. Then you could write rules to check against the count that you manage in that document.

Doug Stevenson
- 297,357
- 32
- 422
- 441
-
now it is possible with a regular client query. - [link](https://firebase.google.com/docs/firestore/query-data/aggregation-queries) – Rajendra A Verma Jul 26 '23 at 16:27
-
now, can we apply in firestore security rule ? – Rajendra A Verma Jul 26 '23 at 16:29