我在一家火药店里收藏了一些东西。有一些规则允许用户在集合中添加文档。
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read: false
allow write: false
allow update: false
allow delete: false
}
match /users/{userId}/widgets/{widgetId} {
allow read: if request.auth.uid == userId
allow delete: if request.auth.uid == userId
allow update: if request.auth.uid == userId
allow create: if request.auth.uid == userId
}
}
}如何防止用户添加超过100个文档?
发布于 2019-10-27 18:20:22
没有简单的规则可以用来限制集合中的文档数量。您将不得不使用另一个文档来保存添加时的运行总数,然后在规则中检查该文档的内容,以确定是否将超过限制。
或者,您可以让客户端调用服务器端函数来编写文档,然后它可以(在自己的代码中)检查集合是否会变得太大。
https://stackoverflow.com/questions/58573251
复制相似问题