jovan jovan - 1 year ago 88
Node.js Question

Access remote MongoDB database?

I've mostly worked with PHP/MySQL but I've now been handed a Node.js/MongoDB project on Github.

Having gone through a Mongo tutorial, I feel I understand the concept to a reasonable extent now, but I am still unsure how to do the most basic thing - view the Mongo database associated with the project.

In the config file, I found the following:

module.exports = {
database: {
url: 'localhost:27017/app_name'

But seeing how I'm on a remote machine, how do I reach the database? Do I need to ask the previous dev for the DB so I can set it up locally?

Searching the code for the word
it only appears in
so that's not a lot of help.

Answer Source

means the DB is in the local machine in which your are developing your app.

In your case, you have MONGO DB installed in your local machine and run the project.

Otherwise if you have a centralized DB then you have to configure that IP here as follows:

Also configure your mongodb.config of your remote DB to accept the connection from your local machine by changing the "BIND IP"

module.exports = {
    database: {
        url: 'yourRemoteIP:27017/app_name'