mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: wip migrate server to nestjs
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { Knex } from 'knex';
|
||||
import { Global, Module, Scope } from '@nestjs/common';
|
||||
import { TENANCY_DB_CONNECTION } from '../TenancyDB/TenancyDB.constants';
|
||||
import { Item } from '../../../modules/Items/models/Item';
|
||||
import { Account } from '@/modules/Accounts/models/Account';
|
||||
|
||||
const models = [Item, Account];
|
||||
const modelProviders = models.map((model) => {
|
||||
return {
|
||||
provide: model.name,
|
||||
inject: [TENANCY_DB_CONNECTION],
|
||||
scope: Scope.REQUEST,
|
||||
useFactory: async (tenantKnex: Knex) => {
|
||||
return model.bindKnex(tenantKnex);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [...modelProviders],
|
||||
exports: [...modelProviders],
|
||||
})
|
||||
export class TenancyModelsModule {}
|
||||
Reference in New Issue
Block a user