英文:
Is there a way to check the size of a Cloud Firestore collection using Security Rules?
问题
在我的应用程序中,每个用户在我的数据库的用户集合中都有一个文档。在每个用户的文档下,都有一个用于该用户上传的食物的子集合。默认情况下,我希望限制用户不能向其个人子集合中添加超过25种食物。是否可以通过安全规则检查集合大小是否<= 25?
英文:
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?
答案1
得分: 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论