Meteor,'/ users / insert'已经定义 [英] Meteor, '/users/insert' is already defined

查看:151
本文介绍了Meteor,'/ users / insert'已经定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建基本的管理面板,我没有使用MongoDB。



为了开发目的,我留下了 autopublish insecure
为了从数据库( Accounts-ui + Accounts-facebook )呈现用户,我需要一个处理程序 Users = new Mongo.Collection(users); 但在编译期间有以下错误:

 '/ users / insert'已定义。 

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(){
//启动时在服务器上运行的代码
});
}




  • facebook登录在另一个文件中配置


解决方案

由于用户的集合是自动定义的,因此无法重新定义。 >

您可以引用现有集合:



而不是:

  Users = new Mongo.Collection(users); 

使用

  Users = Meteor.users; 


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

解决方案

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;

这篇关于Meteor,'/ users / insert'已经定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆