-
Notifications
You must be signed in to change notification settings - Fork 283
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
Example of Bridge Tables #454
Comments
Hey @kferrone, What about https://github.com/RobinBuschmann/sequelize-typescript#many-to-many? :) |
So I was definitely a little blind and missed that section, thank you. Unfortunately these dang bridge tables are just not working for me. I can't get them to work both directions. I can only ever get one of the two models to accept a BelongsToMany annotation. Basically I can have a
Here is my codes:
Please help me understand what is wrong?!?! |
Hey @kferrone, can you share your repo with me, so that I can check? I assume it has something to do with where you are importing your models from: |
OK so I can't give the full project I'm on at work but I did simplify what I'm doing down to just using Here is the repo I made real quick this morning: kferrone/sequel_fun The repo shows off perfectly my issue if you were to un-comment the lines at the bottom of the |
OK .... Your assumption about where I was importing from is correct, i.e. import { . . . } from './'. Why the heck would that be an issue??? All I did was export the default classes in the index like below.
Is this an issue because they become an |
For instance if you define a relation between two models with // a.model.ts
import {B} from './b.model.ts';
new B(); // b.model.ts
import {A} from './a.model.ts';
new A(); This example throws an error. With your index.ts a similar thing happens. I need some time to check what the exact issue is. |
@kferrone Does my suggestion already helped you? |
Oh yeah everything worked fine. My issue was indeed how I was importing. You do have to import the referenced entities directly from their files, i.e. no redirecting through index.js. Thank you very much. |
Would be nice to see an example of how to make a proper bridge table relationship (aka Many to Many) using
sequelize-typescript
. Since no examples, I must trial and error till I figure it out. Wish me luck . . .The text was updated successfully, but these errors were encountered: