use*_*701 2 android firebase firebase-security google-cloud-firestore
遵循文档的测试收集组 ( https://firebase.google.com/docs/firestore/security/rules-query#collection_group_queries_and_security_rules )
Firestore 安全规则
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /forums/{forumid}/posts/{post} {
allow read: if true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 Android 应用上查询(使用 Firestore 19.0.1)
FirebaseFirestore.getInstance().collectionGroup("posts").get().addOnSuccessListener { queryDocumentSnapshots ->
Log.d(TAG, "queryDocumentSnapshots " + queryDocumentSnapshots.size())
}.addOnFailureListener {
Log.d(TAG, "exception" + it)
}
Run Code Online (Sandbox Code Playgroud)
获取异常 PERMISSION_DENIED:权限缺失或不足。
Edw*_*Liu 10
您需要在路径中添加通配符变量以使其适用于集合组查询。如果您更仔细地阅读,那在文档中:)
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{path=**}/posts/{post} {
allow read: if true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1044 次 |
最近记录: |