我有一个基于Authentication和的颤振应用程序,我通过 firebase添加了用户(蓝色按钮),并在代码中保留了ID,以便这个用户是administrator,的常规用户可以通过应用程序创建一个帐户(电子邮件和密码),我想要的是确保administrator是唯一可以从数据库中删除数据的人,而其他用户只允许读写,所以我这样做了:
我将CloudFi还原项目中的角色更改为:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match
我正在构建一个同时使用Room和Firestore的android应用程序。应用程序将有一个存储在Firestore中的长长的项目列表。当用户第一次启动应用程序时,应用程序将读取Firestore中的所有项目并将它们存储在Room中,从那时起,用户应用程序将从Room中读取项目列表。现在,这个项目列表将更改,但大约每月一次,所以我需要一个系统,我可以在Firestore中更新列表,然后向所有用户发送项目列表已更改的消息。然后,他们必须执行一次获取操作,以便从Firestore获取更新后的项目列表,并将其写入Room。
不能使用Firestore listener,因为每次用户打开item li
我目前正在将我的Firebase实时数据库转换为使用新版本的Firestore。
我想按键查找文档。以前,在Firebase实时中,我可以这样做:
getSingleRouteById (key) {
const ref = firebaseDb.ref('/data/')
// now search for data with that key several nested layers down
return ref.child(key)
.once('value')
.then((snapshot) => {
我将在Firestore中的单个文档的不同字段上运行10更新。
someDocRef.update({
[field_1]: "value1"
});
someDocRef.update({
[field_2]: "value2"
});
And so on...
真正要发生的是:
// PSEUDO CODE
1. An admin script will update 10 documents
2. A cloud function with a Firestore trigger will run 10 times
because of
我们可以使用经过身份验证的用户的UID安全地查询文档,并使用如下的防火墙规则:
service cloud.firestore {
match /databases/{database}/documents {
match /stories/{storyid} {
// Only the authenticated user who authored the document can read or write
allow read, write: if request.auth != null && request.auth.uid ==