Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: A method named '/users/insert' is already defined

Tags:

mongodb

meteor

I've just installed the accounts-google and accounts-ui packages and I'm getting the error:

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

My code is currently very simple (very new to this!). Here's 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>

and 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();
    }

  });
}

What am I doing wrong here?

like image 771
babbaggeii Avatar asked May 25 '15 09:05

babbaggeii


1 Answers

Maybe your code is clashing with Meteor default users collection.

You don't need to define a Mongo.Collection to deal with your app users, Meteor comes with its own baked in collection named Meteor.users, use this instead, or rename your collection to something else.

like image 180
saimeunt Avatar answered Oct 09 '22 03:10

saimeunt