question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'findOne' does not exist on type

See original GitHub issue

Issue 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:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
cjackson234commented, May 13, 2018

User is your entity. So yeah, that won’t work.

Try: getRepository(User).findOne({ email: "lala@lala.com" });

3reactions
pleerockcommented, May 14, 2018

@cjackson234 actually he used active record model and extends BaseEntity so all those methods are available for him in a user class.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found