Может кто-нибудь объяснить мне, что я делаю неправильно, когда использую параметры для моего предложения where?
Этот следующий блок выдает мне ошибку под ним:
@EntityRepository(Something)
export class SomethingRepository extends Repository<Something>{
findByUserAndSomethingById(userId: number, spotId: number){
const thing = this.createQueryBuilder('something')
.where('something.userId = :id', {id: userId})
.andWhere('something.id = :id',{id: spotId}).getOne();
return thing;
}
}
QueryFailedError: column something.userid does not exist
Этот запрос дает мне правильный результат.
@EntityRepository(Something)
export class SomethingRepository extends Repository<Something>{
findByUserAndSomethingById(userId: number, spotId: number){
const thing = this.createQueryBuilder('something')
.where(`"something"."userId" = ${userId}`)
.andWhere('something.id = :id',{id: spotId}).getOne();
return thing;
}
}
Обновление: пример репо для воспроизведения и выписка типа на github.