initial commit
This commit is contained in:
17
schema/index.ts
Normal file
17
schema/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
"use node"
|
||||
import { dataSource } from "./data-source";
|
||||
import { UserEntity } from "./entity/UserEntity";
|
||||
|
||||
|
||||
let dbInstance = dataSource;
|
||||
// you can add a try catch
|
||||
export const dbSource = async () => {
|
||||
|
||||
if(!dataSource.isInitialized) {
|
||||
dbInstance = await dataSource.initialize();
|
||||
}
|
||||
|
||||
return {
|
||||
userRepository: dbInstance.getRepository(UserEntity),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user