Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 用于比较InputData和现有数据的firestore规则_Angularjs_Firebase_Google Cloud Firestore_Firebase Security - Fatal编程技术网

Angularjs 用于比较InputData和现有数据的firestore规则

Angularjs 用于比较InputData和现有数据的firestore规则,angularjs,firebase,google-cloud-firestore,firebase-security,Angularjs,Firebase,Google Cloud Firestore,Firebase Security,如何编写firestore规则来比较th文档中的数据与传入数据中的数据 实际上,仅当新数据的开始日期和门厅号不等于现有数据的开始日期和门厅号时,我才想将新文档插入或写入firestore集合 my db的结构如下图所示 查看firestore安全规则 查看firestore安全规则 您需要调整文档的结构。将文档上的自定义ID设置为类似于{date}{hall}(即2018-05-04_1)。这样做的缺点是,您需要一个firestore触发器来监视创建事件,并根据需要进行更新,以确保ID的格式正确

如何编写firestore规则来比较th文档中的数据与传入数据中的数据

实际上,仅当新数据的开始日期和门厅号不等于现有数据的开始日期和门厅号时,我才想将新文档插入或写入firestore集合

my db的结构如下图所示


查看firestore安全规则


查看firestore安全规则


您需要调整文档的结构。将文档上的自定义ID设置为类似于{date}{hall}(即2018-05-04_1)。这样做的缺点是,您需要一个firestore触发器来监视创建事件,并根据需要进行更新,以确保ID的格式正确。由于Firestore安全规则中的限制,我相信这是实现您要求的唯一方法

service cloud.firestore {
    match /databases/{database}/documents {

        match /events/{eventId} {
            allow read: if true;
            allow create: if !exists(get(/databases/$(database)/documents/events/$(eventId));
            allow update: if false; // Depends if you want to be able to update documents
        }

    }
}

您需要调整文档的结构。将文档上的自定义ID设置为类似于{date}{hall}(即2018-05-04_1)。这样做的缺点是,您需要一个firestore触发器来监视创建事件,并根据需要进行更新,以确保ID的格式正确。由于Firestore安全规则中的限制,我相信这是实现您要求的唯一方法

service cloud.firestore {
    match /databases/{database}/documents {

        match /events/{eventId} {
            allow read: if true;
            allow create: if !exists(get(/databases/$(database)/documents/events/$(eventId));
            allow update: if false; // Depends if you want to be able to update documents
        }

    }
}

这是我的firestore规则,但它仍然不工作
service cloud.firestore{match/databases/{database}/documents{match/{document=**}{allow read:if true;allow write:if(request.resource.data.start!=resource.data.start);}}
请查看我的其他答案这是我的firestore规则,但它仍然不起作用
service cloud.firestore{match/databases/{database}/documents{match/{document=**}{allow read:if true;allow write:if(request.resource.data.start!=resource.data.start);}
请查看我的其他答案