0

I've got an auth_token table and user table. I'd like to resolve a user from a given auth token using the query builder. The issue I'm having is that after joining, the return type still thinks it's going to be an AuthToken. Is there a way to tell the query builder to use the joined entity instead?

return await this.authTokenRepository
  .createQueryBuilder()
  .where({
    token: token
  })
  .innerJoinAndSelect(User, 'user')
  .getOne();
4

1 回答 1

0

如果要返回用户类型的实体,我建议使用用户存储库:

return await this.userTokenRepository
  .createQueryBuilder('user')
  .leftJoinAndSelect('user.token', 'token')
  .where({
    token: token
  })
  .getOne();
于 2018-04-15T17:59:14.150 回答