Javascript Meteor用户帐户:核心角色为空

Javascript Meteor用户帐户:核心角色为空,javascript,authentication,meteor,atmosphere,meteor-accounts,Javascript,Authentication,Meteor,Atmosphere,Meteor Accounts,我正在努力学习流星通过视频教程完成的代码没有得到同样的结果。代码如下: Meteor.startup(function(){ if(Meteor.users.find().count() < 1){ var users= [ { name: "Superuser", email: "admin@example.com", roles: ['admin']

我正在努力学习流星通过视频教程完成的代码没有得到同样的结果。代码如下:

Meteor.startup(function(){
if(Meteor.users.find().count() < 1){
    var users= [
        {
            name: "Superuser",
            email: "admin@example.com",
            roles: ['admin']
                        }
                ];

    _.each(users, function(user){
        var id;

        id = Accounts.createUser({
            email: user.email,
            password: "password",
            profile:{
                name: user.name
            }
        });

        if(user.roles.length > 0){
            Roles.addUsersToRoles(id, user.roles);
        }
    });
}
Meteor.startup(函数(){ if(Meteor.users.find().count()<1){ 变量用户=[ { 名称:“超级用户”, 电子邮件:“admin@example.com", 角色:['admin'] } ]; _.每个(用户、功能(用户){ 变量id; id=Accounts.createUser({ 电子邮件:user.email, 密码:“密码”, 简介:{ 名称:user.name } }); 如果(user.roles.length>0){ Roles.addUsersToRoles(id,user.Roles); } }); } }))

假设Meteor.roles.find。(.fetch()控制台应该出现:对象名:“admin”\u id。“随便什么”;但是我的爸爸让我空了

我正在使用alanning:atmospherejs中的角色


提前谢谢

您是否安装了帐户用户界面和帐户密码软件包?这可能与此有关。我建议你安装meteortoys:allthings来检查你的数据库有什么问题

Meteor.startup(函数(){
Meteor.startup(function() {
    if (Meteor.users.find().count() < 1) {
      var users = {
        name: "Superuser",
        email: "admin@example.com",
        roles: ['admin']
      };
      var id;
      id = Accounts.createUser({
        email: user.email,
        password: "password",
        profile: {
          name: user.name
        }
      });
      if (user.roles.length > 0) {
        Roles.addUsersToRoles(id, user.roles, 'defaultgroup');
      }
    });
}
if(Meteor.users.find().count()<1){ 变量用户={ 名称:“超级用户”, 电子邮件:“admin@example.com", 角色:['admin'] }; 变量id; id=Accounts.createUser({ 电子邮件:user.email, 密码:“密码”, 简介:{ 名称:user.name } }); 如果(user.roles.length>0){ Roles.addUsersToRoles(id,user.Roles,'defaultgroup'); } }); }
您确定要在服务器端运行此操作吗?您在Mongo数据库中看到新用户了吗?是的,它位于服务器端,Mongo上的db.roles.find()显示为空:/这个工具看起来不错,@ParthRaval Toys Meteor显示:Meteor.loginServiceConfiguration参数:none\u roles参数:none Meteor\u autoupdate\u clientVersion参数:none,您必须在用户模型中添加角色:{type:Object}这起作用了,最后请注意,没有进行更改,因为以前创建了用户,只是删除了数据库,一切正常。多谢各位@帕特拉瓦尔