Set MONGO_URL on a Meteor project within the settings.json file

0

I'm starting to work with Meteor and I'm having a lot of trouble with something that should be simple: change the connection string with a mongodb own. I already searched the internet, also for the stackoverflow itself here / a>, here and in other different links but none of them give me a solution that is "politically correct".

From what I saw in the Meteor documentation, I can work with a settings.json file where it should let me set the variable MONGO_URL manually as well.

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

The problem is that I do not know how to force the meteor to run it at all times, without having to define the --settings function on the command line because if I generate an application in the production environment, I do not see the --settings as functional, I actually need Meteor to not create a database and return an error when it can not find the database.

EDIT: I was able to make it connect on its own basis 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 the Meteor to go to another base, and it will not return an error if it does not find the base, but if it does not find it, it will create its own base .

    
asked by anonymous 23.12.2016 / 12:08

1 answer

0

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

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

Then, you just run the following command:

$ meteor npm run start

Ideally, you should leave MONGO_URL from the settings.json file for the production bench.

    
06.05.2017 / 18:46