我正在尝试设置 Firestore 安全性,以便用户可以在此处读取和写入自己的文档是我用来将数据添加到数据库的代码
data() {
return {
order: {
price: null,
amount: null,
comment: null,
createdAt: new Date().toString().slice(0, 25),
uid: fb.auth().currentUser.uid
}
}
}
sendBuy() {
db.collection("orders").add(this.order);
}
这是读取数据的代码
readData() {
let uid = fb.auth().currentUser.uid;
db.collection("orders")
.where("uid", "==", uid)
.get()
.then(querySnapShot => {
querySnapShot.forEach(doc => {
console.log(doc.id, "=>", doc.data());
});
});
}
我试过的firestore规则不起作用
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /orders/{uid} {
allow read, write: if request.resource.data.uid == request.auth.uid;
}
}
}
请问我怎样才能做到这一点
ABOUTYOU
暮色呼如
相关分类