我有一个简单的加密货币应用程序,它使用API来获取价格。我使用Firestore来存储我的API密钥,我的应用程序在启动时从Firestore中检索我的API密钥。我的API键是我在Firestore中拥有的唯一数据。由于我的应用程序不允许用户创建配置文件/帐户,所以我的规则中不包括用户身份验证。我对Firestore的安全规则是:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /Data/{Data} {
allo
我试图在Google中创建一个节点,并使用它的唯一id在中创建一个相同名称的文档。
我正在使用谷歌的PHP客户端:
我已经阅读了他们的文档:
这是我的代码:
<?php
use \Google\Cloud\Firestore\FirestoreClient;
use \Google\Cloud\Core\Timestamp;
use \Google\Cloud\Firestore\Transaction as FirestoreTransaction;
use \grptx\Firebase as FirebaseClient;
class FirestoreTest
{
p
在Cloud数据库中,由于一个集合下的文档过多,我通常用来读取文档的快照代码无法工作。请看下面的代码,这是我们试图读取的数据。在使用期间,应用程序挂起,导致设备也挂起。
我们已经初始化了应用程序并创建了firestoredb连接,同时使用下面的代码加载了我们的应用程序。
//firebase is a global namespace from which all Firebase services are accessed.
firebase.initializeApp(firebaseConfig);
//Initialize firebase
我可以发送一个在Firestore中创建文档,但我想知道是否有方法可以将数组中的n个userID/user documentID添加到来自swift或typescript中的Cloud Functions的文档中。 我知道我可以在一个数组中查询和获取users集合中的所有用户,然后将n个随机用户添加到要在Firestore中创建的文档中,但是如果我有一百万个用户,那么就会有一百万次读取,我正在努力避免这种情况。 代码 if let data = self.imageView.image?.pngData() {
let postID = APIs.posts.coll
我正在制作一个简单的Instagram克隆,其中有一个页面供用户发布图片,另一个页面用于查看其他用户发布的图片。在Cloud Firestore中,我有一个collection of Users,我不知道该如何存储这些图片。我的collection of posts应该与collection of users级别相同,还是每个User document都指向一个sub-collection of posts?我觉得让每个User Document指向一个Sub-Collection of Posts对于Database的组织来说更有意义,但同时,我认为从Database获得“帖子”会更困难,而
我目前有安全规则,允许用户只从名为"153“的集合中读取。
在Android中,我访问Firestore并调用Firestore实例上的.collection("153").get()...从该集合中检索数据。
相反,如果Android代码读取.collection("999").get...,则该权限将被拒绝,这是应该的。
安全规则:
service cloud.firestore {
match /databases/{database}/documents {
// FULL ADMIN ACCESS
match /{docum
在Firebase Firestore中,我只允许(自定义分配的)管理员编写/更新/删除资源,为此我有以下安全规则:
service cloud.firestore {
match /databases/{database}/documents {
match /resources {
allow read;
allow write, update, delete: if get(/users/$(request.auth.uid).isAdmin);
}
match /resources/{resource} {
allow r
我的意思是,我知道这些是什么,但我对安全规则有点困惑,例如:
service cloud.firestore {
match /databases/{database}/documents {
// This is probably a mistake
match /spaceships { // <= what is this a collection or a document?
allow read;
// In spite of the above line, a user can't read any document wit
为Firestore编写规则,似乎自定义变量不起作用。有谁知道为什么或曾见过类似的行为吗?使用下面的命令,我被拒绝了访问,尽管uid位于admin数组中。
service cloud.firestore {
match /databases/{database}/documents {
match /conferences/{confid} {
allow read,write: if request.auth.uid in get(/databases/$(database)/documents/conferences/$(confid)).d
我的Firestore数据库目前是这样设置的:
组有成员(用户列表),我想查询和查找所有组的特定用户。我发现collectionGroup查询应该是解决方案,下面是我的查询代码。
let db = Firestore.firestore()
let ref = db.collectionGroup("members").whereField("id", isEqualTo: userID)
ref.getDocuments(completion: { (snapshot, error) in
guard let snapsh
我有一个“游戏”的收集与一个“水平”的子收藏的火药库。我试图设置安全规则,以便您只能访问您创建的游戏或级别。
所有文档(游戏或级别)都有一个authorId字段,其中包含创建它们的用户的uid。我尝试过这个规则,但仍然有一个Missing or insufficient permissions错误:
service cloud.firestore {
match /databases/{database}/documents {
match /games/{document=**} {
allow read, write: if document.data.