-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Typescript example of M:N relationship (belongsToMany) with through table attributes #11644
Comments
Hello!
There is a typo here, |
@papb Thanks for pointing that out. I fixed it. I finally figured out how to make it work. More examples would be good, however. |
Nice!!
I agree 😬 Would you be willing to post how did you finally make it work? |
Hello, can somebody please show an example project to reach M:N realtionships. Thanks. |
Hey @Crodaycat & others I am also working on my first Sequelize / Typescript selfstudy project. I found this example to be pretty useful (though it is from 2 years ago) |
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
there is very less documentation for sequlize typescript
but i still don't know how to do the same with this syntax
|
Issue Description
Examples of using Typescript with many-to-many relationships (i.e.
belongsToMany
<->belongsToMany
)What was unclear/insufficient/not covered in the documentation
Only simple relationship examples exist: i.e
hasMany
Additional context
I've looked through the type definitions and tests and I'm coming up empty-handed.
Simple example:
How do I declare the
addAccount
method of classUser
? My through table (AccountUser
) has a single attribute (role
). I've looked through the code (i.e.associations/belongs-to-many.d.ts
) but I'm stumped. It appears thatBelongsToManyAddAssociationMixin
takes 3 arguments but when I express something like:it complains with
Generic type 'BelongsToManyAddAssociationMixin' requires 2 type argument(s)
Some help and guidance would be greatly appreciated. I'd be happy to contribute to the Typescript documentation page to cover this use case.
Is this issue dialect-specific?
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: