I usually use this code to create a repository:
import { EntityRepository, Repository } from 'typeorm'
import { User } from './user.entity'
@EntityRepository(User)
export class UserRepository extends Repository<User> {
getInactiveUsers(): Promise<User[]> {
return this.createQueryBuilder()
.where('isActive = :active', { active: false })
.getMany()
}
}
However, now EntityRepository
is deprecated. I found a reference but I think it's quite complex. I wonder if there is a simpler way to solve it?
Yes, it is deprecated, you can create custom repository with DataSource, you can read this.