且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在Meteor App中连接到备用Mongo DB

更新时间:2023-11-18 16:33:16

就像@ dr.dimitr说env vars仅在生产过程中使用(例如,将您的模数应用程序与它们提供的模数db连接或使用其他模数) ,在开发过程中,您可以像这样使用mongo驱动器.

Like @dr.dimitr say env vars are only used on the production process (for example connecting your modulus app with the modulus db they provide or another different), on the developing process you can use the mongo drive like this.

if(Meteor.isServer){
    Meteor.startup(function () {
       var myDatabase = new MongoInternals.RemoteCollectionDriver("<mongo url>");
       MyCollection = new Mongo.Collection("collection_name", { _driver: myDatabase });
     });
   }

现在您需要知道URL <mongo url>的名称,该名称可能类似于mongodb://127.0.0.1:27017/localmeteor

Now you need to know name of the url <mongo url> which could be something like mongodb://127.0.0.1:27017/local or meteor

一些相关帖子-(1)(2)