Reputation: 1692
I have this line in two .js files in Meteor:
merchants = new Mongo.Collection('merchants');
It blows up with the error message below. Why?
Tried adding var
Removing the line in one of the files helps.
What am I doing wrong?
`W20150614-11:20:50.527(-7)? (STDERR) at app\signUp\signUp.js:1:48
W20150614-11:20:50.527(-7)? (STDERR) at app\signUp\signUp.js:54:3
W20150614-11:20:50.529(-7)? (STDERR) at E:\work\meteor3\app\merchant\.m
eteor\local\build\programs\server\boot.js:222:10
W20150614-11:20:50.529(-7)? (STDERR) at Array.forEach (native)
W20150614-11:20:50.529(-7)? (STDERR) at Function._.each._.forEach (C:\Users\
I\AppData\Local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bund
le\server-lib\node_modules\underscore\underscore.js:79:11)
W20150614-11:21:03.189(-7)? (STDERR)
W20150614-11:21:03.190(-7)? (STDERR) C:\Users\I\AppData\Local\.meteor\packages\m
eteor-tool\1.1.3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\
future.js:245
W20150614-11:21:03.191(-7)? (STDERR)
throw(ex);
W20150614-11:21:03.191(-7)? (STDERR)
^
W20150614-11:21:03.192(-7)? (STDERR) Error: A method named '/merchants/insert' is already defined
W20150614-11:21:03.193(-7)? (STDERR) at packages/ddp/livedata_server.js:1461
:1
W20150614-11:21:03.193(-7)? (STDERR) at Function._.each._.forEach (packages/
underscore/underscore.js:113:1)
W20150614-11:21:03.194(-7)? (STDERR) at [object Object]._.extend.methods (pa
ckages/ddp/livedata_server.js:1459:1)
W20150614-11:21:03.194(-7)? (STDERR) at [object Object].Mongo.Collection._de
fineMutationMethods (packages/mongo/collection.js:904:1)
W20150614-11:21:03.195(-7)? (STDERR) at new Mongo.Collection (packages/mongo
/collection.js:209:1)
W20150614-11:21:03.196(-7)? (STDERR) at app\signUp\signUp.js:1:48
W20150614-11:21:03.196(-7)? (STDERR) at app\signUp\signUp.js:54:3
W20150614-11:21:03.197(-7)? (STDERR) at E:\work\meteor3\app\merchant\.m
eteor\local\build\programs\server\boot.js:222:10
W20150614-11:21:03.198(-7)? (STDERR) at Array.forEach (native)
W20150614-11:21:03.199(-7)? (STDERR) at Function._.each._.forEach (C:\Users\
I\AppData\Local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bund
Upvotes: 0
Views: 36
Reputation: 1146
You only need one new Mongo.Collection
declaration per collection in meteor app.
Upvotes: 1