我试图允许每个用户使用firestore读写自己的数据,但我遇到了权限不足错误.我不知道为什么.
我为我的firestore制定了这些规则.我只是try 将用户的UID(存储在createdBy属性中)与请求中可访问的用户UID进行比较.认证.uid
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /bots/{id} {
allow read, write: if request.auth != null && resource.data.createdBy == request.auth.uid;
match /order_history/{id} {
allow read, write: if request.auth != null && resource.data.createdBy == request.auth.uid;
}
}
}
}
以及检索数据的查询:
const orders = await getDocs(query(collectionGroup(db, 'order_history'), orderBy('datetime'), where('createdBy', '==', user.uid)));
setOrders(orders.docs.map((doc) => ({
...doc.data()
})))
}
Here is an overview of my Firestore organization:
我的正面是FirebaseError: Missing or insufficient permissions
.
我做错了什么?