Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Typeorm lazy relations #5

Open
bogdan opened this issue Jan 14, 2020 · 1 comment
Open

Support Typeorm lazy relations #5

bogdan opened this issue Jan 14, 2020 · 1 comment

Comments

@bogdan
Copy link

bogdan commented Jan 14, 2020

I am not able to use assocOne for lazy relations:

class Post {

@OneToMany()
author: Promise<User>
}

const userFactory = new UserFactory(User)
new Factory(Post)
  .assocOne("author", userFactory);
lib/jest/factories.ts|55 col 21 error 2345| 2345: Argument of type 'Factory<User>' is not assignable to parameter of type 'Factory<Promise<User>>'. Types of property 'Entity' are incompatible. Type 'IConstructable<User>' is not assignable to type 'IConstructable<Promise<User>>'. Type 'User' is not assignable to type 'Promise<User>'.

Is it possible to add the support?

@fruwe
Copy link

fruwe commented Mar 15, 2021

For the time being a (not so pretty) workaround is .assocOne("author", userFactory as any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants