从Collection切换到SmartCollection

时间:2013-10-19 14:01:48

标签: javascript collections meteor

我将我的代码从Collection转换为SmartCollection :(在second.js中是主要的js文件)

 Testcases = new Meteor.Collection('testcases');
 Backup = new Meteor.Collection('backup');

进入:

Testcases = new Meteor.SmartCollection('testcases');
 Backup = new Meteor.SmartCollection('backup');

切换后应用程序出错:

W2042-21:55:27.312(8)? (STDERR) /Users/dan/Documents/js_app/second/.meteor/local/build/programs/server/boot.js:185
W2042-21:55:27.313(8)? (STDERR) }).run();
W2042-21:55:27.313(8)? (STDERR)    ^
W2042-21:55:27.315(8)? (STDERR) TypeError: undefined is not a function
W2042-21:55:27.315(8)? (STDERR)     at app/second.js:1:49
W2042-21:55:27.316(8)? (STDERR)     at app/second.js:10:3
W2042-21:55:27.316(8)? (STDERR)     at /Users/dan/Documents/js_app/second/.meteor/local/build/programs/server/boot.js:154:10
W2042-21:55:27.316(8)? (STDERR)     at Array.forEach (native)
W2042-21:55:27.317(8)? (STDERR)     at Function._.each._.forEach (/Users/dan/.meteor/tools/a80b2d5689/lib/node_modules/underscore/underscore.js:79:11)
W2042-21:55:27.317(8)? (STDERR)     at /Users/dan/Documents/js_app/second/.meteor/local/build/programs/server/boot.js:81:5

我是否需要更新任何内容。鉴于在服务器js代码中,我只实现了2个集合的简单初始化:

 Meteor.publish('testcases', function() {
return Testcases.find({});
});
   Meteor.publish('backup', function() {
      return Backup.find({});
});

1 个答案:

答案 0 :(得分:1)

“undefined is not a function”错误表示未安装SmartCollection包。

确保您已遵循安装说明,如果是大气包,请确保使用'mrt'而不是'meteor'运行您的应用。