且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Cloud Firestore规则中-如何检查键是否为空

更新时间:2023-11-29 16:22:58

阅读Firestore安全规则文档的列表比较

Reading the list comparisons of the Firestore Security rules documentation here, we can see that hasAll returns true if all values are present in the list.

// Allow read if one list has all items in the other list
allow read: if ['username', 'age'].hasAll(['username', 'age']);

request.resource.data是包含字段和值的映射.为了使用hasAll,我们必须首先获取键作为值列表,如

The request.resource.data is a map containing the fields and values. In order to use hasAll, we must first get the keys as a list of values as shown here.

!resource.data.keys().hasAll(['assignee'])