How can I write a security rule that limits the number of document created in a batch?
My use case is that on user creation, I create the user document containing its data, and I also create a few other docs - in the same collection. How can I limit the number of such creations to 5 for instance? I could explicitly name the documents "1", "2", "3", "4" and "5" but this would not be pretty
match /users/{user}/subcoll/{subcolldoc}{
allow create: if request.auth.uid != null
&& request.auth.uid == user
&& getAfter(/databases/$(database)/documents/users/$(user)).data.createdon == request.time // So it is in the same batch/
&& subcolldoc in ["1", "2", "3", "4", "5"]