简体   繁体   English

Firebase 安全规则 Map 方法 get() 是否算作文档读取?

[英]Does Firebase security rules Map method get() count as a document read?

I've been writing security rules for my app and I've come across a spot of confusion.我一直在为我的应用程序编写安全规则,但遇到了一些困惑。 In the docs it says that using a get() call in security rules count as a read and you are limited to 10 per request.在文档中,它说在安全规则中使用 get() 调用算作一次读取,并且每个请求限制为 10 个。 In my rules I've been using.get() so if some incoming data isn't defined, it doesnt break my rules and I can type check it.在我的规则中,我一直在使用.get(),因此如果未定义某些传入数据,它不会违反我的规则,我可以输入检查它。 Here's an example.这是一个例子。

 function incomingData(){ return request.resource.data } function isUserIsAuth(){ return request.auth.= null } function isUserOwner(userID){ return request.auth.uid == userID } function isString(data){ return data is string || data == null } function isBool(data){ return data is bool || data == null } function isNumber(data){ return data is number || data == null } function validateUserTypes(){ return isBool(incomingData(),get("social_status". null)) && isBool(incomingData(),get("tag_status". null)) && isNumber(incomingData(),get("num_photos". null)) && isString(incomingData(),get("first_name". null)) && isString(incomingData(),get("last_name". null)) && isString(incomingData(),get("location". null)) && isString(incomingData(),get("caption_text". null)) && isString(incomingData(),get("uid_auth". null)) && isString(incomingData(),get("uid_instagram". null)) && isString(incomingData(),get("uid_snapchat". null)) && incomingData(),get("gender", null) in ["Male", "Female", "Other", "Prefer Not To Say"] }

The.get() method allows me to type get without worrying if the data is defined on the request or not. .get() 方法允许我输入 get 而不必担心数据是否在请求中定义。 My question is, would this.get() method use reads?我的问题是,this.get() 方法会使用读取吗?

Thanks!谢谢!

No. The documentation is referring to the top-level function get() that read a documents, not the Map object method get() that you're using here.不。文档指的是读取文档的顶级 function get (),而不是您在此处使用的 Map object 方法get()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 安全规则 (.read) - Firebase security rules (.read) 为什么 firebase_firestore 安全规则不适用于文档读取 - Why firebase_firestore security rules not worked for document read 处理从Firebase获取的文档快照的数据是否算读? - Does processing the data of a document snapshot obtained from Firebase count as a read? Firebase 云存储安全规则中Firestore文档参考如何使用? - How to use Firestore Document Reference in Firebase Cloud Storage Security Rules? 获取 Firebase 文档快照到 Map - Get Firebase Document Snapshot to a Map 为本地应用程序保留 firebase firestore 和存储安全规则(允许读取、写入 = true)是否有风险? - is it risky to keep firebase firestore & storage security rules (allow read , write = true) for a local application? Firebase Firestore 安全规则 - 根据资源读取所有嵌套文档(但它为空) - Firebase Firestore security rules - read all nested docs based on resource (but it's null) Firebase 移动应用安全规则 - Firebase security rules for mobile apps Firebase 安全规则未显示任何数据 - No data displayed with Firebase Security Rules firebase 嵌套子文档的安全规则 - Security rules for nested subdocuments with firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM