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

bug: ORM Model Types are not correct #52

Open
G0maa opened this issue Apr 7, 2023 · 1 comment
Open

bug: ORM Model Types are not correct #52

G0maa opened this issue Apr 7, 2023 · 1 comment

Comments

@G0maa
Copy link
Owner

G0maa commented Apr 7, 2023

  • Reason:
    // Relations
    @BelongsToMany(() => Subject, () => ActiveSubject)
    subjects!: Subject[];
    @BelongsToMany(() => Teacher, () => ActiveSubject)
    teachers!: Teacher[];
    @HasMany(() => Student)
    students!: Student[];
  • This makes Model.find() have e.g. subjects defined, when it isn't, it's only defined if you include:{} corresponding models in the relation.
@G0maa
Copy link
Owner Author

G0maa commented Apr 7, 2023

  • I feel like this to-do here is also related:
    // To-Do: This is not correctly typed.
    // i.e.: user.userDetails & user[roleName] do not exist in compile time,
    // although they exist at run time.
    const user = await User.create(
    {
    ...zUser,
    userDetails: { ...zUserDetails },
    [roleName]: roleData,
    },
    {
    include: [roleModels[zUser.role], UserDetails],
    }
    );

@G0maa G0maa changed the title bug: Model Types are not correct bug: ORM Model Types are not correct Apr 7, 2023
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

No branches or pull requests

1 participant