2015-06-14 47 views
0

我此行兩個.js文件中的流星:錯誤從兩個.js文件指的是同一Mongo.Collection流星

merchants = new Mongo.Collection('merchants'); 

它與下面的錯誤消息炸燬。爲什麼?

嘗試添加var

刪除行中的文件的一個幫助。

我在做什麼錯?

`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 

回答

1

您只需要在流星應用程序中爲每個集合聲明一個new Mongo.Collection聲明。

+0

我可以使用全局變量的集合嗎? – Ruby

+0

是的,它將在服務器和客戶端共享 –

+0

Yikes!我希望我可以使用局部變量。謝謝你的答案。 – Ruby