【发布时间】:2015-02-28 22:50:01
【问题描述】:
我正在尝试连接到作为 Meteor 应用程序位于机器上的 Mongo 数据库。这是我的应用程序中的两个文件:
a.js:
if (Meteor.isServer) {
var database = new MongoInternals.RemoteCollectionDriver("mongodb://127.0.0.1:3001/meteor");
Boxes = new Mongo.Collection("boxes", { _driver: database });
Meteor.publish('boxes', function() {
return Boxes.find();
});
}
b.js:
if (Meteor.isClient) {
Meteor.subscribe('boxes');
Template.homeCanvasTpl.helpers({
boxes: function () {
return Boxes.find({});
}
});
}
但我不断收到“模板助手中的异常:ReferenceError:未定义框”错误 - 有什么想法吗?
【问题讨论】:
-
您尚未在客户端定义集合。您必须在服务器和客户端上都定义它。我认为您在客户端上定义它时不必传递任何第二个参数,因为您仍将使用与服务器的默认连接。