【发布时间】:2019-10-16 13:03:45
【问题描述】:
我目前制定了一些基本规则来访问我的 Firestore 数据库。规则详述如下。谁能帮我理解为什么第二个代码块会导致权限错误?我正在尝试将图像添加到尚不存在的子集合中。谢谢
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /projects/{project} {
allow read, write: if request.auth.uid != null
}
match /users/{userId} {
allow create
allow read: if request.auth.uid != null
allow write: if request.auth.uid == userId
}
match /notifications/{notification} {
allow read: if request.auth.uid != null
}
}
}
这是我的应用代码:
await firestore.add(
{
collection: "users",
doc: user.uid,
subcollections: [{ collection: "photos" }]
},
{
name: imageName,
url: downloadURL
}
);
【问题讨论】:
-
我不明白这个对
firestore.add()的调用。它看起来不像原生 SDK 提供的任何东西。您是否在 Firestore SDK 之上使用了一些包装器或其他 SDK? -
您好,我正在使用 reduxfirestore
-
您好,我正在使用 reduxfirestore,但如果我完全打开数据库进行读写,它就可以工作。
标签: javascript firebase google-cloud-firestore firebase-security