Skip to content

Commit 789a302

Browse files
committed
support uri
1 parent 887bacc commit 789a302

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/transformer.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,28 @@ module.exports = {
3535
})
3636
},
3737

38+
/**
39+
* Create Sequelize object based on config options
40+
* @param {Object} config Trails.js store
41+
* @return {Sequelize} Sequelize instance
42+
*/
43+
createFromConfig (config) {
44+
if (config.uri) {
45+
return new Sequelize(config.uri, _.clone(config)) // Sequelize modify options object
46+
}
47+
else {
48+
return new Sequelize(config.database, config.username, config.password, config)
49+
}
50+
},
51+
3852
/**
3953
* Transform the Trails.js "stores" config into a Sequelize object
4054
*/
4155
transformStores (app) {
4256
const stores = app.config.database.stores
4357
const sequelize = {}
4458
Object.keys(stores).forEach(key => {
45-
sequelize[key] = new Sequelize(stores[key].database, stores[key].username, stores[key].password, stores[key])
59+
sequelize[key] = this.createFromConfig(stores[key])
4660
sequelize[key].trailsApp = app
4761
})
4862

0 commit comments

Comments
 (0)