Firebase Rules for Cloud Firestore to limit maximum number of documents
I have following use case.. I don't want to allow user control document limit in cloud firestore, I want to have firebase rule restrict it.
For eg. I have a products collection, user can do pagination (max=10) per page. if its browser side, user can easily change and get all the products list. Is there any settings or rules to control this?
You can protect this using the
queryproperty of the
requestobject (see docs). Basically you can write a rule with a condition on the
allow read: if request.query.limit != 10
The above rule will prevent the query from going through if the limit is not set to 10.