2015-05-25 14 views
9

Ho appena installato i conti-google e pacchetti di conti-ui e sto ottenendo l'errore:Errore: un metodo chiamato '/ utenti/insert' è già definito

W20150525-10:41:42.384(1)? (STDERR)   
W20150525-10:41:42.384(1)? (STDERR) /home/andy/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245 
W20150525-10:41:42.384(1)? (STDERR)       throw(ex); 
W20150525-10:41:42.384(1)? (STDERR)        ^
W20150525-10:41:42.449(1)? (STDERR) Error: A method named '/users/insert' is already defined 
W20150525-10:41:42.449(1)? (STDERR)  at packages/ddp/livedata_server.js:1461:1 
W20150525-10:41:42.449(1)? (STDERR)  at Function._.each._.forEach (packages/underscore/underscore.js:113:1) 
W20150525-10:41:42.449(1)? (STDERR)  at [object Object]._.extend.methods (packages/ddp/livedata_server.js:1459:1) 
W20150525-10:41:42.449(1)? (STDERR)  at [object Object].Mongo.Collection._defineMutationMethods (packages/mongo/collection.js:904:1) 
W20150525-10:41:42.449(1)? (STDERR)  at new Mongo.Collection (packages/mongo/collection.js:209:1) 
W20150525-10:41:42.449(1)? (STDERR)  at app/meteor.js:1:44 
W20150525-10:41:42.449(1)? (STDERR)  at app/meteor.js:16:3 
W20150525-10:41:42.450(1)? (STDERR)  at /home/andy/dev/meteor/.meteor/local/build/programs/server/boot.js:222:10 
W20150525-10:41:42.450(1)? (STDERR)  at Array.forEach (native) 
W20150525-10:41:42.450(1)? (STDERR)  at Function._.each._.forEach (/home/andy/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11) 
=> Exited with code: 8 

Il mio codice è attualmente molto semplice (molto nuovo per questo!). Ecco meteor.html:

<head> 
    <title>Hubbub</title> 
</head> 

<body style="padding-top: 100px;"> 
    <div class="container"> 
     <div class="row"> 
      <div class="col-xs-12"> 
       {{> loginButtons}} 
       {{> main }} 
      </div> 
     </div> 
    </div> 
</body> 

<template name="main"> 

<table class="table table-bordered table-striped table-hover"> 
    <thead> 
     <tr> 
      <th>id</th> 
      <th>name</th> 
      <th>age</th> 
      <th>date</th> 
     </tr> 
    </thead> 
    <tbody> 
     {{#each users}} 
     <tr> 
      <td>{{_id}}</td> 
      <td>{{name}}</td> 
      <td>{{age}}</td> 
      <td>{{date}}</td> 
     </tr> 
     {{/each}} 
    </tbody> 
</table> 


</template> 

e meteor.js:

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

if (Meteor.isClient) { 

    Template.main.helpers({ 

    users: function() { 
     return Users.find(); 
    }, 
    date: function(){ 
     return moment(this.date).fromNow(); 
    } 

    }); 
} 

Che cosa sto facendo male qui?

risposta

13

Forse il tuo codice è in contrasto con la collezione di default di Meteor users.

Non è necessario definire un Mongo.Collection per gestire gli utenti della propria app, Meteor viene fornito con una propria collezione in forno denominata Meteor.users, utilizzare invece questa opzione o rinominare la raccolta in qualcos'altro.

+1

Dovrebbero fornire un avvertimento più esplicito ad un certo punto – Rayjax

+0

Come aggiornare il documento dell'utente utilizzando Meteor.users? – Pravin

+0

up @Pravin domanda .... Devo recuperare il totale di utenti in db .. – YoBre

Problemi correlati