Programatically setting MONGO_URL to point 2 apps to the same database


#1

So upon discovering settings.json and putting in the MONGO_URL in the object like so

{
    "MONGO_URL": "mongodb://127.0.0.1:4000/the_app_db",
}

I wanted to set this on startup by modifying the environment variable programaticlaly but it is not working … I did something like …

Meteor.startup(function () {
    process.env.MONGO_URL = Meteor.settings.MONGO_URL;
});

And (surprise surprise) it is not working. Is it possible to set this up on startup? I do not wish to use terminal nor “package.json” in the root dir. I did not find much info on the matter.

And now for the questions to you gentlemen:

1 - How do I programatically make both meteor apps point to the same db (not via terminal) as I would like to specify the database where things are stored. (Note: I DID NOT install a separate mongodb installation. I am using the local 32 bit version installed with meteor. )

2 - Also Meteor creates 2 db’s; one named “meteor” and another named “local”. what does “local” store? Can anyone provide further insight on these two?


#4

The two threads are unrelated however I provided you with a solution for your scenario in the appropriate thread.


#5

You could use the MongoInternals connection driver, or regular DDP connection. Check it here.


#6

Thanks will look into it. At a first glance I spotted what I was doing wrong, I was trying to combine the Mongo Collection with the MongoInternals and it seems like they cannot be used together :frowning:


#7

Take a look at the link, you can, but instead of connection, you can use _driver