I'm building an API with Express+TypeORM. This is my ormconfig.json:
{
"type": "postgres",
"host": "localhost",
"port": "5432",
"username": "mdsp9070",
"password": "mdsp9070",
"database": "mesha",
"entities": ["./src/entities/*.ts"],
"migrations": ["./src/shared/infra/typeorm/migrations/*.ts"],
"cli": {
"migrationsDir": "./src/shared/infra/typeorm/migrations"
}
}
And my entity is defined as:
import {
Entity,
Column,
PrimaryGeneratedColumn,
} from "typeorm";
@Entity("users")
export class User {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column()
name: string;
@Column()
email: string;
@Column()
birthYear: string;
@Column()
phoneNumber: string;
@Column()
photo: string;
}
On my CreateUserUseCase, I call this repository like:
...
private usersRepository: IUsersRepository;
// receives ormRepository, that's users repository
constructor() {
this.usersRepository = getCustomRepository(UsersRepository);
}
...
but I'm getting this error: [ERROR] 13:08:39 ConnectionNotFoundError: Connection "default" was not found.
No, connection is not being called after getCustomRepository as I call the file on the index of my server.
full github repo: https://github.com/Mdsp9070/mesha