Set MONGO_URL in a Meteor project within the file Settings.json

Asked

Viewed 155 times

0

I’m starting to work with the Meteor and I’m having a hard time with something that should be simple: changing the connection string with a mongodb itself. I’ve searched the internet, also for stackoverflow itself here, here and other different links but none of them gives me a solution that is "politically correct".

From what I saw in the Meteor documentation, I have how to work with a file settings.json where it should let me define the variable MONGO_URL manually like this.

{
  "env":{
    "MONGO_URL": "mongodb://localhost:27017/mydb"
  }
}

The problem is that I don’t know how to force the Content to run it always, without having to define the function on the command line --settings because if I generate an application in a production environment, I don’t see --Settings as functional, I actually need Meteor not to create a database and return an error when it doesn’t find the database.

EDIT: I managed to get it to connect on a base of its own when I created a BAT with the commands below:

SET MONGO_URL=mongodb://localhost:27017/mydb
meteor

But I do not agree that this is the only way to get Meteor to access another base, besides it will not return me an error if I do not find the base, on the contrary, if I do not find it will create its own base.

1 answer

0

Meteor allows you to create custom commands in the file package.json. For example, create in the file package.json the following:

{
  "scripts": {
    "start": "MONGO_URL=mongodb://localhost:27017/yourdb meteor run"
  }
}

Then you just run the following command:

$ meteor npm run start

The ideal is that you leave the MONGO_URL of the file Settings.json to the production database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.