2015-06-14 48 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