Skip to content

Commit

Permalink
Merge pull request #14 from fabrix-app/v1.1
Browse files Browse the repository at this point in the history
[feat] use fabrix log for sequelize
  • Loading branch information
scott-wyatt authored Aug 8, 2018
2 parents 0902f56 + 46857ea commit bd2a6eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions lib/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,20 @@ export const Transformer = {
* @param {Object} app.config.store
* @return {Sequelize} Sequelize instance
*/
createConnectionsFromConfig (config: {[key: string]: any}) {
createConnectionsFromConfig (app: FabrixApp, config: {[key: string]: any}) {
const logger = function(str) {
app.log.debug(str)
}
if (config.uri) {
return new Sequelize(config.uri, Object.assign({}, config)) // Sequelize modify options object
// Sequelize modify options object
return new Sequelize(config.uri, Object.assign({}, config, { logging: logger }))
}
else {
return new Sequelize(
config.database,
config.username || process.env.POSTGRES_USER,
config.password || process.env.POSTGRES_PASSWORD,
config
Object.assign({}, config, { logging: logger })
)
}
},
Expand Down Expand Up @@ -249,7 +253,7 @@ export const Transformer = {
const stores = Transformer.pickStores(app.config.get('stores'))
const sequelize = {}
Object.keys(stores).forEach(key => {
sequelize[key] = Transformer.createConnectionsFromConfig(stores[key])
sequelize[key] = Transformer.createConnectionsFromConfig(app, stores[key])
sequelize[key].fabrixApp = app
sequelize[key].migrate = stores[key].migrate
sequelize[key].models = {}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fabrix/spool-sequelize",
"version": "1.1.9",
"version": "1.1.10",
"description": "Spool - Datastore Spool for Sequelize.js http://sequelizejs.com",
"scripts": {
"build": "tsc -p ./lib/tsconfig.release.json",
Expand Down Expand Up @@ -51,7 +51,7 @@
"sequelize": "^4.37.10"
},
"devDependencies": {
"@fabrix/fabrix": "^1.1.3",
"@fabrix/fabrix": "^1.1.4",
"@fabrix/lint": "^1.0.0-alpha.3",
"@fabrix/spool-router": "^1.1.3",
"@fabrix/spool-tapestries": "^1.1.3",
Expand Down

0 comments on commit bd2a6eb

Please sign in to comment.