Meteor, '/users/insert' is already defined

别来无恙 提交于 2019-12-25 16:55:51

问题


I'm creating basic Administration Panel and I didn't work with MongoDB yet.

For development purposes I left autopublish and insecure in the project. In order to render users from database (Accounts-ui + Accounts-facebook) i need a handler for Users = new Mongo.Collection("users"); but during compilation there is following error:

'/users/insert' is already defined.

HTML

<body>
  {{> loginButtons}}

  {{#each users}}
    {{> user}}
  {{/each}}
</body>

<template name="user">
  <li>{{profile.name}}: {{_id}}</li>
</template>

JS

Users = new Mongo.Collection("users");

if (Meteor.isClient) {

  Template.body.helpers({
    users: function () {
      return Users.find({});
    }
  });

  Accounts.onLogin(function(){
    console.log("logged in: " + Meteor.userId());
  });

}

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}
  • facebook login is configured in another file

回答1:


Since the user's collection is automatically defined you can't re-define it.

You can though reference the existing collection:

Instead of:

Users = new Mongo.Collection("users");

Use

Users = Meteor.users;


来源:https://stackoverflow.com/questions/30784311/meteor-users-insert-is-already-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!