Meteor,'/ users / insert'已经定义 [英] Meteor, '/users/insert' is already defined
问题描述
我正在创建基本的管理面板,我没有使用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屋!