【问题标题】:Use a MongoHQ db with Meteor on localhost在本地主机上使用带有 Meteor 的 MongoHQ 数据库
【发布时间】:2013-03-24 19:37:40
【问题描述】:

我想知道如何让 MongoHQ 数据库在我本地安装的 Meter 上工作。

我尝试在启动流星时使用 settings.json 方法或 MONGO_URL=mongodb://user:pass@xxxx.mongohq.com:10061/xxxx,但两者都不起作用,并且可能是错误的方法。

【问题讨论】:

    标签: meteor mongohq


    【解决方案1】:

    在项目目录中的终端中像这样运行它

    MONGO_URL=mongodb://user:pass@xxxx.mongohq.com:10061/xxxx meteor
    

    export MONGO_URL=mongodb://user:pass@xxxx.mongohq.com:10061/xxxx
    meteor
    

    【讨论】:

    • 这确实让它使用了 mongohq 但它没有做任何收藏。
    • Meteor.startup(function () { var Customers = new Meteor.Collection("customers"); var Contacts = new Meteor.Collection("contacts"); console.log("Were Here" ); if (Customers.find() === 0) { console.log("没有为客户找到任何东西"); Customers.insert({id: Customers.find().count() + 1, name: "测试Customer"}); }; console.log("Were now here"); if (Contacts.find({}) === 0) { console.log("没有为客户找到"); Contacts.insert({ id: Contacts.find().count() + 1, first_name: "Test", last_name: "Contact"}); }; });
    • 是服务器端代码还是客户端代码?您必须等待订阅完成,然后才能检查集合是否已填满。顺便说一句,它适用于普通的本地 mongodb 数据库吗?
    • 我相信它工作正常,但是我似乎无法将 MONGO_URL 更改回流星默认值,因此我可以从控制台使用流星 mongo 对其进行测试以确保。
    • 你用的是导出方式吗?使用新终端
    猜你喜欢
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-27
    • 1970-01-01
    • 2019-09-03
    相关资源
    最近更新 更多