Argument of type '{ email: string; }' is not assignable to parameter of type 'FindManyOptions<User>'

huangapple go评论58阅读模式
英文:

Argument of type '{ email: string; }' is not assignable to parameter of type 'FindManyOptions<User>'

问题

I am trying to pass string to the find method, but it shows this error. Also, this message follows:

尝试将字符串传递给find方法,但出现了此错误。此外,以下消息也显示:

Object literal may only specify known properties, and 'email' does not exist in type 'FindManyOptions'.ts(2345)

英文:
create(email: string, password: string) {
    const user = this.repo.create({ email, password });

    return this.repo.save(user);
}

findOne(id: number) {
    return this.repo.findOneBy({id});
}

find(email: string) {
    return this.repo.find({ email });
}
}

I am trying to pass string to the find method, but it shows this error. Also, this message follows:

Object literal may only specify known properties, and 'email' does not exist in type 'FindManyOptions&lt;User&gt;'.ts(2345)

答案1

得分: 1

你应该使用where而不仅仅是使用电子邮件。您可以查看此帖子

return this.repo.find({ where:{email} });

英文:

You should use where instead of just using email. You can see this post.

return this.repo.find({ where:{email} });

huangapple
  • 本文由 发表于 2023年6月1日 06:25:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76377657.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定