var mongoose = require('mongoose')

var MONGO_DB;
 var DOCKER_DB = process.env.DB_1_PORT;
 if ( DOCKER_DB ) {
   MONGO_DB = DOCKER_DB.replace( "tcp", "mongodb" ) + "/dev_db";
 } else {
   MONGO_DB = process.env.MONGODB;
 }

mongoose.connect(MONGO_DB)

var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));

module.exports = db
