Search code examples
mongodbdeployddatabase

Mongo db database not accessible from shell, data storage


I am working with deployd which uses mongoDB as a db on Ubuntu OS.

All databases of mongoDB are accessible from within mongodb shell but my question is when I create a new project with deployd I can store/read/modify records but this new database is not accessible from mongodb shell, how do i do that?.

Database files for this new project are stored within the application directory not in mongoDB default data directory.

Also what's the difference of mongoDB as a database within application and MongoDB as a global database for all applications.

Currently all collections are accessible using dpd object like

dpd.albums.get(inputParams, function(resultSet, err){ //handle result});

While I would like to access these collections using something like

db.albums.find(); //within mongod shell

Solution

  • It seems there are a few misconceptions here about the deploying with "deployd".

    Firstly "deployd" depends on an existing mongoDB installation on it's deployed host or is otherwise configured to use a host on another server. So where "data files" are kept are generally a point of condifuration. All that "deployd" tries to do is start the "mongod" instance as it's own instance is started should the configuration be local.

    No matter what you do, all of the options are available in configuration. There is a good sample in the documentation here:

    var server = deployd({
      port: process.env.PORT || 5000,
      env: 'staging',
      db: {
        host: 'my.production.mongo.host',
        port: 27105,
        name: 'my-db',
        credentials: {
          username: 'username',
          password: 'password'
        }
      }
    });
    

    As you can see the host and port settings are specified in the configuration of the application itself, so where you are not using the default "mongoDB" host and port then add them to the command line options, as in:

    mongo --host my.production.mongo.host --port 27105
    

    So even on the same localhost, note that the instance does not use the default 27017 port but a different one that you would need to specify when connecting.

    Also see the mongo shell command documentation as well as the deployd documentation.