这些是我当前的安全规则:
service cloud.firestore {
match /databases/{database}/documents {
match /tournaments/{tournament=**} {
allow update, delete: if request.auth.uid == resource.data.author;
allow create: if request.auth.uid != null;
allow read: if true;
}
}
}
一切正常,由于“缺少权限或权限不足”,仅更新或删除不起作用
这是我的代码
mDocRef
.update(key, score)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "DocumentSnapshot successfully updated!");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error updating document", e);
}
});
mDocRef引用路径为“ tournaments / tournamentID / aColletion / aDocument”的文档
以下是创建mDocRef的代码:
mTournamentDocRef = mTournamentColRef.document();
mDocRef = mTournamentDocRef.collection("aCollection").document();
一些注意事项:
谢谢您的帮助!
答案 0 :(得分:0)
我将Firebase用户的ID添加到创建的每个文档中,以获取所需的结果
var async = require('async');
// custom imports
var User = require('../models/user');
var Article = require('../models/article');
var List1Objects = User.find({});
var List2Objects = Article.find({});
var resourcesStack = {
usersList: List1Objects.exec.bind(List1Objects),
articlesList: List2Objects.exec.bind(List2Objects),
};
async.parallel(resourcesStack, function (error, resultSet){
if (error) {
res.status(500).send(error);
return;
}
res.render('home', resultSet);
});
答案 1 :(得分:0)
我检查了文档,这些是您要寻找的规则:
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
}
以及文档链接作为参考:https://firebase.google.com/docs/firestore/security/rules-conditions?authuser=0