Property 'findOne' does not exist on type
See original GitHub issueIssue type:
[x] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
Hello!
So I’ve got this entity:
@Entity()
class User extends BaseEntity {
@PrimaryGeneratedColumn() id: number;
@Column({ type: "text", unique: true })
@IsEmail()
email: string;
@Column({ type: "bigint", nullable: true })
facebookId: number;
@Column({ type: "text" })
firstName: string;
@Column({ type: "text" })
lastName: string;
}
export default User;
And later on in my code I’m trying to do:
const user: User = await User.findOne({ email: "lala@lala.com" });
But I’m getting an error that says:
Property 'findOne' does not exist on type 'User'
What am I doing wrong?
Cheers!
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Am I missing a package? Property 'findOne' does not exist on ...
I've been given the websites at my company to maintain and I've run into the error (Property 'findOne' does not exist on type...
Read more >error ts2339: property 'findone' does not exist on type ...
You are trying to access the attribute on the array of LogRepair that is why the error message includes the square brackets after...
Read more >TypeORM vs Prisma
This page compares Prisma and TypeORM. If you want to learn how to migrate from TypeORM to Prisma, check out this guide.
Read more >nodejs/node - Gitter
TypeError : Cannot read property 'findOne' of undefined. how can a function from the documentation not exist ????? _. devsnek. @devsnek.
Read more >TypeScript - Sequelize
As Sequelize heavily relies on runtime property assignments, TypeScript won't be very useful out of the box. A decent amount of manual type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
User is your entity. So yeah, that won’t work.
Try:
getRepository(User).findOne({ email: "lala@lala.com" });
@cjackson234 actually he used active record model and extends
BaseEntity
so all those methods are available for him in a user class.