sgo*_*die 7 javascript schema meteor meteor-autoform
我一直在我的Meteor项目上使用Collection2和Autoform,让事情变得容易多了!
但是,当我删除不安全时,它不再插入(Autoform提交按钮).我期待这个!
但是,我搜索过,我找不到让它工作的标准方法?我有lib文件夹中定义的架构,并自动创建窗体我作为一个template.i一个快速表单就知道我必须为允许客户端插入(我宁愿不做)或者其与传送到服务器端(也许方法?)
我们欢迎所有的建议!我正在寻找实现它的标准方法.
sgo*_*die 10
经过多次挖掘后找到了我自己的答案.为插入,更新和删除创建了允许规则:
Posts = new Mongo.Collection('posts');
//SECURITY - Allow Callbacks for posting
Posts.allow({
insert: function(userId, doc) {
// only allow posting if you are logged in
return !! userId;
},
update: function(userId, doc) {
// only allow updating if you are logged in
return !! userId;
},
remove: function(userID, doc) {
//only allow deleting if you are owner
return doc.submittedById === Meteor.userId();
}
});
//Schema then defined as usual
Run Code Online (Sandbox Code Playgroud)
只是一个注释,submittedById是我的集合中保存userId的字段.如果你把它称为不同的东西,改变它!
希望这可以帮助有类似问题的人.
归档时间: |
|
查看次数: |
1209 次 |
最近记录: |