规则。火库
Cloud Firestore 安全规则的上下文特定变量和方法。
此命名空间中的函数仅在service cloud.firestore { ... }
块内可用,并且在使用时不需要添加前缀( get()
而不是firestore.get()
)。
接口
要求
Firestore 操作的传入请求上下文。
资源
正在读取或写入的 Firestore 文档。
特性
要求
请求上下文,包括身份验证信息和待处理数据。
资源
正在读取或写入的资源。
方法
存在
存在(路径)返回rules.Boolean
检查文档是否存在。
范围 | |
---|---|
小路 | 路径。 值不能为空。 |
- 退货
non-null rules.Boolean
如果资源存在则为 true。
例子
// Check if another document exists
allow write: if exists(/databases/$(database)/documents/things/other)
存在于之后
containsAfter(path) 返回rules.Boolean
检查文档是否存在,假设当前请求成功。相当于 getAfter(path) != null。
范围 | |
---|---|
小路 | 路径。 值不能为空。 |
- 退货
non-null rules.Boolean
如果资源存在则为 true。
得到
get(path) 返回rules.firestore.Resource
获取 firestore 文档的内容。
范围 | |
---|---|
小路 | 路径。 值不能为空。 |
- 退货
non-null rules.firestore.Resource
文档,如果不存在则为null。
例子
// Get the 'thing1' document from the 'things' collection
get(/databases/$(database)/documents/things/thing1)
获取之后
getAfter(path) 返回rules.firestore.Resource
获取文档的预计内容。返回文档,就好像当前请求已成功一样。对于验证属于批量写入或事务一部分的文档很有用。
范围 | |
---|---|
小路 | 路径。 值不能为空。 |
- 退货
non-null rules.firestore.Resource
文档,如果不存在则为null。