-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: add tests for raw * test: pass process.env.DB to connection.ts * chore: logging for postgres & mysql * fix: raw: false for multi patch * test: custom NotFound with integer * chore: gh actions global env * chore: init mysql gh action * chore: console.log connection * chore: rm console.log
- Loading branch information
1 parent
df848da
commit eb57f7c
Showing
6 changed files
with
329 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
import type { Options } from 'sequelize'; | ||
import { Sequelize } from 'sequelize'; | ||
|
||
export default (DB?: 'postgres' | 'mysql') => { | ||
export default (DB?: 'postgres' | 'mysql' | string) => { | ||
const logging: Options['logging'] = false; | ||
|
||
if (DB === 'postgres') { | ||
return new Sequelize('sequelize', 'postgres', 'password', { | ||
host: 'localhost', | ||
dialect: 'postgres' | ||
}); | ||
return new Sequelize( | ||
process.env.POSTGRES_DB ?? 'sequelize', | ||
process.env.POSTGRES_USER ?? 'postgres', | ||
process.env.POSTGRES_PASSWORD ?? 'password', | ||
{ | ||
host: 'localhost', | ||
dialect: 'postgres', | ||
logging | ||
} | ||
); | ||
} else if (DB === 'mysql') { | ||
return new Sequelize('sequelize', 'root', '', { | ||
host: '127.0.0.1', | ||
dialect: 'mysql' | ||
}); | ||
return new Sequelize( | ||
process.env.MYSQl_DATABASE ?? 'sequelize', | ||
process.env.MYSQL_USER ?? 'root', | ||
process.env.MYSQL_PASSWORD ?? '', | ||
{ | ||
host: '127.0.0.1', | ||
dialect: 'mysql', | ||
logging | ||
} | ||
); | ||
} else { | ||
return new Sequelize('sequelize', '', '', { | ||
dialect: 'sqlite', | ||
storage: './db.sqlite', | ||
logging: false | ||
logging | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.