sequelize-typescript: Problems with multiple relationships
Hi!, in my project I’m getting the following error:
UnhandledPromiseRejectionWarning: Error: Alias cannot be inferred: "ProjectRecurrence" has multiple relations with "Projects"
My code is:
export default class ProjectRecurrence extends Model<ProjectRecurrence> {
...
@ForeignKey(() => Projects)
@IsInt
@Column
project_id: number;
@BelongsTo(() => Projects, 'project_id')
projectIdObject: Projects;
...
@HasMany(() => Projects, 'project_recurrence_id')
projects: Projects[];
}
is a bug? thank you!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (6 by maintainers)
Hey @Dragons0458, your setup is totally fine. The issue is the query itself. You have to tell sequelize-typescript which relation to
ProjectRecurrence
you want to use:Hope this helps. Feel free to close this issue if my answer solves your problem
@Dragons0458 Do you receive the same error? I don’t get any - It’s working very well for me.
Sorry to reopen the thread after so much time, but I have returned to get the same error and I do not know why, the models and classes are the following:
and
and this is the model:
These are the versions I am using:
any solution?
Thank you very much! 😄
ok, ok, I just tried with version 0.6.6 of this library and I do not get the error, sorry for not looking before, thank you very much for the solution to this! 😄