Cloud Firestore安全规则:如何检查属性是否存在? [英] Cloud Firestore security rules: how to check is property exists?

查看:55
本文介绍了Cloud Firestore安全规则:如何检查属性是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查存储库中的文档中是否存在属性. allow update, delete: if resource.data.uid; 在上面的代码中,我有错误属性uid在对象上未定义.",所以我如何检查数据中的uid?

I need to check is property exists in document in store. allow update, delete: if resource.data.uid; in code above i have error "Property uid is undefined on object.", so how i can check is uid in data?

推荐答案

要检查文档是否包含特定字段,我使用in:

To check if the document contains a specific field, I use in:

allow update, delete: if 'uid' in resource.data;

这篇关于Cloud Firestore安全规则:如何检查属性是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆