简体   繁体   中英

Firestore security rules: check a condition for every value in an array

In Firestore security rules, is there any way to check a condition for every value in an array?

I have a document that has a subcollection. The document has an order field which is an array of IDs of documents in the subcollection; this array defines a custom user-defined order for those documents.

I want a security rule that checks that any values added to the order array correspond to a document in the subcollection (ie that the document exists). That is, it needs to check this condition for every value in the array.

What you call an array is known as a List in Firestore security rules, and there are no list comprehension style operations beyond the has* checks for literal values.

The problem is that such a looped check would quickly become a performance (and cost) bottle neck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM