feat: add models init
This commit is contained in:
4
src/modules/init.ts
Normal file
4
src/modules/init.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { useContextKey, useContext } from '@kevisual/use-config/context';
|
||||
import { sequelize } from './sequelize.ts';
|
||||
|
||||
export { sequelize };
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useConfig } from '@kevisual/use-config';
|
||||
import { Sequelize } from 'sequelize';
|
||||
import { useContextKey, useContext } from '@kevisual/use-config/context';
|
||||
|
||||
type PostgresConfig = {
|
||||
postgres: {
|
||||
@@ -19,8 +20,11 @@ if (!postgresConfig) {
|
||||
process.exit(1);
|
||||
}
|
||||
// connect to db
|
||||
export const sequelize = new Sequelize({
|
||||
dialect: 'postgres',
|
||||
...postgresConfig,
|
||||
// logging: false,
|
||||
});
|
||||
export const init = () => {
|
||||
return new Sequelize({
|
||||
dialect: 'postgres',
|
||||
...postgresConfig,
|
||||
// logging: false,
|
||||
});
|
||||
};
|
||||
export const sequelize = useContextKey('sequelize', init);
|
||||
|
||||
Reference in New Issue
Block a user