提前道歉,如果我在使用Meteor/Mongo方面的术语和理解上有任何错误,因为我刚开始学习和开发。
我正在尝试将我的本地Meteor应用程序连接到远程MongoDB,该数据库托管在其他地方。
我的代码如下:
Bills = new Mongo.Collection("bills");
if (Meteor.isClient) {
Meteor.subscribe("bills");
// This code only runs on the client
Template.body.helpers({
documentContent: function () {
return Bills.find();
}
});
Template.documentBody.helpers({
documentContent: function ()
{
var thingy = Bills.find();
console.log(thingy);
return Bills.find({_id: "784576346gf874"});
}
});
}
我已经通过以下方式使用shell连接到了数据库:
$ MONGO_URL="mongodb://mysite.net:27017/legislation" meteor
在我的浏览器中,没有出现任何错误,并且在我定义的模板中看到了 [object Object]。控制台显示本地的 miniCollection,但没有从订阅集合返回任何文档。
我想我要问的是: 如果您要在本地应用程序中连接到远程 MongoDB,您会怎么做?
感谢您抽出时间来阅读,非常感激任何帮助。