【问题标题】:CRUD Meteor accounts-ui users collectionCRUD Meteor 账户-ui 用户合集
【发布时间】:2014-11-12 05:03:47
【问题描述】:

在 Meteor 中,我想将数据(和其他 CRUD 函数)插入到 users 表中,该表是在下载 Meteor 中的 account-ui 和 account-password 包时生成的。我尝试在之前的 client.js 文件中创建一个方法来执行此操作:

Template.Something.events({
     'click .submit': function() {
          users.insert({
               type: $('.something').val()
          });
      }
})

当我尝试时,我得到了一个回应 '未定义用户' 在我的 javascript 控制台中。

除了如何做到这一点,我还想知道 account-ui 和 users 表的源代码实际上在 Meteor 0.9.2.1 中的位置。谢谢!

【问题讨论】:

  • 它做了一些事情,消息说:插入失败:访问被拒绝。不允许在方法“插入”的受限集合上设置验证器。这是什么意思?
  • 你需要...让我添加一个格式化的答案

标签: javascript collections insert meteor


【解决方案1】:
Meteor.users.allow({
  update: function(userId, user){
    // to allow update user just to user, you get it ;)? right?
    // return user._id == userId;
    // to allow all updates
    return true;
  },
  insert: function(userId, user){ /* same as above*/ }
});

你可以把它放在初始化代码上。

【讨论】:

  • 此 sn-p 需要在 updateinsert 方法之间使用逗号。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-08
  • 2015-12-22
  • 2015-03-21
  • 1970-01-01
  • 2013-05-27
  • 2019-07-27
相关资源
最近更新 更多