If accessing Cloud Firestore client-side, is it there a way to limit the number of documents (per collection) that a user can create?
For example, if we have a Firestore rule to
match /users/{userId}/sites/{siteName} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
, this allows an authenticated user to create an unlimited number of documents /users/<UID>/sites/*
. Is this something that can be limited? We can't use get(/databases/$(database)/documents/users/$(userId)/posts)
because get
only takes documents and not collections as its parameter (Firebase Reference) and returns a Resource object.
For any given document, I know we can limit the data set by the user through the request.resource.data
object. Also, this is easy to do server-side (although it requires two network requests rather than one).