Javascript 拒绝mongo集合中文档子集的更新
我在一个集合上有一个集合钩子来生成一个“空日历”。这或多或少是一个需要保持不变的基础,也就是说,拒绝更新Javascript 拒绝mongo集合中文档子集的更新,javascript,node.js,mongodb,meteor,Javascript,Node.js,Mongodb,Meteor,我在一个集合上有一个集合钩子来生成一个“空日历”。这或多或少是一个需要保持不变的基础,也就是说,拒绝更新 Players.after.insert({ // creates an empty calendar Calendars.insert({ playerId: this._id }); }); Calendars.deny({ update: function (userId, doc) { // don't allow "blank" calendar
Players.after.insert({
// creates an empty calendar
Calendars.insert({
playerId: this._id
});
});
Calendars.deny({
update: function (userId, doc) {
// don't allow "blank" calendar to be updated
}
});
在大多数日历上,更新是完全可以的,但是在这些通过这个钩子插入的特定日历上,我想拒绝更新
Players.after.insert({
// creates an empty calendar
Calendars.insert({
playerId: this._id
});
});
Calendars.deny({
update: function (userId, doc) {
// don't allow "blank" calendar to be updated
}
});
使用meteor管理文档集合中文档子集的拒绝更新的安全方法是什么?鉴于没有人回答,请详细介绍我的评论。一种方法是在“空”记录上设置一个标志。例如:
Players.after.insert({
// creates an empty calendar
Calendars.insert({
playerId: this._id
preventUpdate: true
});
});
然后,您的deny函数可以是:
Calendars.deny({
update: function (userId, doc) {
return doc.preventUpdate === true
}
});
这应该是安全的,因为deny函数中的
doc
参数是数据库中未修改的文档,因此无法从客户端对其进行篡改。请展开我的评论,因为没有人回答。一种方法是在“空”记录上设置一个标志。例如:
Players.after.insert({
// creates an empty calendar
Calendars.insert({
playerId: this._id
preventUpdate: true
});
});
然后,您的deny函数可以是:
Calendars.deny({
update: function (userId, doc) {
return doc.preventUpdate === true
}
});
这应该是安全的,因为deny函数中的
doc
参数是数据库中未修改的文档,因此无法从客户端对其进行篡改。请展开我的评论,因为没有人回答。一种方法是在“空”记录上设置一个标志。例如:
Players.after.insert({
// creates an empty calendar
Calendars.insert({
playerId: this._id
preventUpdate: true
});
});
然后,您的deny函数可以是:
Calendars.deny({
update: function (userId, doc) {
return doc.preventUpdate === true
}
});
这应该是安全的,因为deny函数中的
doc
参数是数据库中未修改的文档,因此无法从客户端对其进行篡改。请展开我的评论,因为没有人回答。一种方法是在“空”记录上设置一个标志。例如:
Players.after.insert({
// creates an empty calendar
Calendars.insert({
playerId: this._id
preventUpdate: true
});
});
然后,您的deny函数可以是:
Calendars.deny({
update: function (userId, doc) {
return doc.preventUpdate === true
}
});
这应该是安全的,因为deny函数中的
doc
参数是数据库中未修改的文档,因此无法从客户端进行篡改。您可以使用“defineProperty”并将“writable”设置为“false”吗?在其他空日历上设置标志可能是最容易的。例如preventUpdate:true
。然后在update deny函数中:return doc.preventUpdate===true
您可以使用“defineProperty”并将“writable”设置为“false”吗?在其他空日历上设置标志可能是最容易的。例如preventUpdate:true
。然后在update deny函数中:return doc.preventUpdate===true
您可以使用“defineProperty”并将“writable”设置为“false”吗?在其他空日历上设置标志可能是最容易的。例如preventUpdate:true
。然后在update deny函数中:return doc.preventUpdate===true
您可以使用“defineProperty”并将“writable”设置为“false”吗?在其他空日历上设置标志可能是最容易的。例如preventUpdate:true
。然后在update deny函数中:return doc.preventUpdate==true