jhoxray / meteor-mongo-extensions

Very simple implementation of some of mongodb aggregation framework functions for Meteor
42 stars 28 forks source link

Duplicated instance inside mapReduce #5

Open zvictor opened 11 years ago

zvictor commented 11 years ago

I instantiate my collection somewhere in my code and I use it as out in my mapReduce call.

TmpConnexions = new Meteor.Collection("connexions_tmp");

...
    out: {
      merge: "connexions_tmp"
    }
...

However it seems that mongodb-aggregation tries to instantiate it again on mongodb-aggregation/server.coffee:53, which is not allowed by Meteor, leading us to this error:

 Exception in callback of async function Error: A method named '/connexions_tmp/insert' is already defined
     at _.extend.methods (packages/livedata/livedata_server.js:1222)
     at Function._.each._.forEach (packages/underscore/underscore.js:87)
     at _.extend.methods (packages/livedata/livedata_server.js:1220)
     at Meteor.Collection._defineMutationMethods (packages/mongo-livedata/collection.js:610)
     at new Meteor.Collection (packages/mongo-livedata/collection.js:176)
     at Meteor.methods._callMapReduce (packages/mongodb-aggregation/server.coffee:53:18)
     at maybeAuditArgumentChecks (packages/livedata/livedata_server.js:1358)
     at packages/livedata/livedata_server.js:1287
     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:31)
     at _.extend.apply (packages/livedata/livedata_server.js:1286)
jhoxray commented 11 years ago

Will need to check for already existing collections and make sure not to create again in mapReduce, thanks for pointing out. The problem is it's hidden API now in Meteor so it will be another hack. Oh, wait, the whole package is that anyway :)