trailsjs / trails

:evergreen_tree: Modern Web Application Framework for Node.js.
http://trailsjs.io
Other
1.66k stars 70 forks source link

Database config does not work for environments #227

Closed sschimmel closed 8 years ago

sschimmel commented 8 years ago

Issue Description

I have a default config in config/database.js and a different config in config/env/testing.js. When I set the environment to testing the database configuration from testing.js is not used. When I remove the stores and models objects from database.js trails just does not detect any database configuration.

database.js:

module.exports = {

  /**
   * Define the database stores. A store is typically a single database.
   *
   * Set production connection info in config/env/production.js
   */
  stores: {

    mongodbstore: {
      // should be 'create' or 'drop'
      migrate: 'create',
      uri: 'mongodb://localhost:27017/jungo',
      options: {}
    }
  },

  models: {
    defaultStore: 'mongodbstore',
    migrate: 'create'
  }
}

testing.js:

'use strict'

module.exports = {

  trailpack: {
    disabled: [
      'repl'
    ]
  },
  database: {
    stores: {
      mongodbstore: {
        migrate: 'create',
        uri: `mongodb://${process.env.MONGO_HOST}:27017/jungo`,
        options: {}
      }
    },
    models: {
      defaultStore: 'mongodbstore',
      migrate: 'create'
    }
  }
}

Environment

jaumard commented 8 years ago

Hi,

What ORM did you use ? with the trailpack-ORM version please. Also check you set NODE_ENV to testing. You also need the last version of trails here 1.0.0-beta-1 is not the last 1.0.4 is.

sschimmel commented 8 years ago

Hi,

Manually updated to 1.0.4 as npm did not detect it, didn't help to solve the issue. The ORM I use is mongoose with version 0.4.1. of trailpack-mongoose.

ycpatel813 commented 8 years ago

@sschimmel check https://github.com/trailsjs/trailpack-mongoose/tree/master/config and check your trailpack-mongoose config for database.js file is included or not?? May be it will help.

konstantinzolotarev commented 8 years ago

Moved this issue into trailpack-mongoose repo. https://github.com/trailsjs/trailpack-mongoose/issues/16

Closing this.