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

Add Belongs To Many relation #36

Open
kiaking opened this issue Nov 17, 2020 · 12 comments
Open

Add Belongs To Many relation #36

kiaking opened this issue Nov 17, 2020 · 12 comments
Labels
enhancement New feature or request

Comments

@kiaking
Copy link
Member

kiaking commented Nov 17, 2020

Ref: https://vuex-orm.org/guide/model/relationships.html#many-to-many

@kiaking kiaking added the enhancement New feature or request label Nov 17, 2020
@kiaking kiaking added this to the v1.0.0-alpha.1 milestone Nov 17, 2020
@smilingkite
Copy link

We're loving it that vuex-orm already has a vue3 compatible branch, but yes -BelongsToMany (or many to many) would be a good addition.

@M3psipax
Copy link
Contributor

Can I ask what's this feature's priority and schedule? I'm trying to use next-vuex-orm in a new project and this would be very helpful.

@kiaking
Copy link
Member Author

kiaking commented Jul 27, 2021

Sorry it's taking long 😓 Because in my use case most of the time I can just use HasManyBy for inverse Has Many relation this is getting pushed back. Really love to see this implemented, but I guess I need a bit more time.

@M3psipax
Copy link
Contributor

Hm, I took a closer look at HasManyBy. It might be enough for me as well. I have a list of objects A with ids and then a list of objects B which each have some number of As, but the As don't care about which Bs are referencing them, so it should work that way. Anyway, I'll stop derailing this issue now. :D

@smilingkite
Copy link

Just FYI - according the the docs @HasManyBy is a decorator - which works only in typescript?

It may be unusual for a project with our level of complexity, but we don't use typescript.

Or is it just that the docs aren't clear on this yet and I could use it without typescript?

@cuebit
Copy link
Member

cuebit commented Jul 28, 2021

@smilingkite you may want to refer to this https://next.vuex-orm.org/guide/relationships/one-to-many.html#one-to-many-by

@salcedo
Copy link

salcedo commented Jan 26, 2022

Any traction on this? I've done some pretty whacky stuff with hasManyBy(), but there's a lot of holes in it that could be solved by bringing back many to many relationships in Vuex ORM.

@salcedo
Copy link

salcedo commented Mar 1, 2022

@kiaking Can you show example of HasManyBy for the inverse relation to "fake" belongsToMany?

I tried this but because the ORM only stores 1 id for each relationship instead of a pivot table, this breaks when models have more than one ManyToMany relationships with eachother.

@mrvanwagoner
Copy link

What is the timeframe for implementing this and morphMany. I am anxious to use these features.

@tintin10q
Copy link

tintin10q commented Apr 16, 2022

Any update on this? In my opnion this was the best part about vuex-orm.

For instance if you have Channels and Users you have Users.subscribed. The model in the middle UserSubbed can than be used to store a date for instance.

This many to many missing is the only feature currenlty stopping me from upgrading my project.

@tintin10q
Copy link

tintin10q commented Apr 17, 2022

Ok turns out you don't actually need belongsToMany.

I made this issue on the pinia-orm repo with an example of how to convert a belongsToMany to HasMany.

CodeDredd/pinia-orm#8

I hope this is helpful to everyone!

@CodeDredd
Copy link

Well i have a working version of it CodeDredd/pinia-orm#79 for pinia which can easly be added back here. I am happy to make an pr if its being merged.

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

No branches or pull requests

8 participants