【发布时间】:2020-12-08 10:56:30
【问题描述】:
使用子关系搜索时,我无法找到行。我尝试了有无承诺,但仍然没有运气。
示例实体:
@Entity('email')
export class Email extends BaseEntity {
@Column({ nullable: false, unique: true })
email: string;
@Column({ default: false })
verified: boolean;
@ManyToOne(type => User, user => user.emails)
user: Promise<User>;
}
@Entity('users')
export class User extends BaseEntity {
@Column({ nullable: false })
name: string;
@OneToMany(type => Phone, phone => phone.user)
emails: Promise<Email[]>;
}
如果我使用以下内容:
// user will remain null
const user = await this.userRepo.findOne({
where: [
{
emails: [
{
email: 'test@test.com'
}
],
],
}
// email will also remain null
const email = await this.emailRepo.findOne({
where: [
{
user: {
name: 'test'
},
],
}
有谁知道如何解决这个问题?我认为这是一个错误。
【问题讨论】:
标签: typeorm typeorm-datamapper node.js-typeorm