我是 firebase 新手,我为我的数据库编写了一些规则,我似乎将它们与在我的 user.js 文件中执行的查询相匹配。我的文档被称为通知,在我的查询中,我首先检查当前用户是否会使用他/她的用户 ID 检索通知,在阅读之前,我仍然需要检查状态是否为真(意味着用户还没有阅读通知) )。但是当我尝试执行它时,它不会读取我的 firestore 数据,我收到此错误:FirebaseError: Missing or insufficient permissions.
这是我的查询:
bindNotificationsByUserId: firestoreAction(async (context, userId) => {
return await context.bindFirestoreRef(
"notification",
db
.collectionGroup("notification")
.where("user_id", "==", userId)
.where("status", "==", true)
.orderBy("created_at", "desc"),
{
serialize,
wait: true
}
);
这是我对这个查询的规则:
match /notification/{notificationId} {
allow read: if isAdmin() || isUserAuthenticated(resource.data.user_id) && resource.data.status == 'true'
}