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