Handling database environment configuration in Sails.js

你。 提交于 2019-11-30 07:26:19

You want to save the actual connection definition in the either development.js or production.js and remove them from connections.js. It's a little non-intuitive.

development.js

module.exports = {
  connections : {
    mongoDev: {
      adapter: 'sails-mongo',
      host: 'localhost',
      port: 27017,
      user: 'username',
      password: 'password',
      database: 'database'
    }
  },
  models: {
    connection: 'mongoDev'
  }    
};

production.js

module.exports = {
  connections : {
    mongoLive: {
      adapter: 'sails-mongo',
      host: 'host.mongolab.com',
      port: 31681,
      user: 'user',
      password: 'password',
      database: 'database'
    } 
  },
  models: {
     connection: 'mongoLive'
  },
  port: 3000,
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!