0.1.0 • Published 1 year ago
typeorm-ns v0.1.0
typeorm namespace
init default datasource
config file: appRootPath/env/development.env
TYPEORM_DEFAULT_CONNECTION=postgresql
TYPEORM_DEFAULT_HOST=
TYPEORM_DEFAULT_PORT=
TYPEORM_DEFAULT_USERNAME=
TYPEORM_DEFAULT_PASSWORD=
TYPEORM_DEFAULT_DATABASE=
TYPEORM_DEFAULT_LOGGING=
TYPEORM_DEFAULT_SYNCHRONIZE=
TYPEORM_DEFAULT_CONNECTION_MAX=10
TYPEORM_DEFAULT_CONNECTION_TIMEOUT=30000
TYPEORM_DEFAULT_IDLE_TIMEOUT=10000
init
import { initDefaultDataSource } from 'typeorm-ns'
initDefaultDataSource()
.then(async () => {
//
})
.catch((err: any) => {
logger.error(err)
})
use repository
import { getRepository } from 'typeorm-ns'
import { EntityA } from '@entity/EntityA'
const aRepo = getRepository(EntityA)
return await aRepo.findAndCount(...)
use transaction
import { getTrxMgr } from 'typeorm-ns'
import { EntityA } from '@entity/EntityA'
return getTrxMgr().transaction(async (trxMgr: EntityManager) => {
const aRepo = trxMgr.getRepository(EntityA)
await aRepo.save(...)
// do something ...
const [items, total] = await aRepo.findAndCount(...)
return { items, total }
})
0.0.20
1 year ago
0.0.21
1 year ago
0.0.22
1 year ago
0.1.0
1 year ago
0.0.18
1 year ago
0.0.19
1 year ago
0.0.17
1 year ago
0.0.16
1 year ago
0.0.15
1 year ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago