英文:
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
英文:
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<User>'.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} });
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论