Adonis Attach many to many relation #2728
Vishwas-verma
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is my schema ,
I want to create project and attach members to it along with there role ,that will be taken as input from user.
Here is my old controller code-
but
attach
function is not allowing me to do can anyone tell how to do it.I have achieved the result in one way by running loop is there any more feasible ways of doing it as I didn't like the way.
My updated controller code is-
Here is my input-
The drawback of this is if we have to update members than we have to detach first members and then attach members that seems to be havoc.
Also as loop is running the attach and detach query will run as many times as many there are members in projects which is not suitable for large cases.
I know it provide
sync
property but using it the correct way in this is problem any suggestions??Beta Was this translation helpful? Give feedback.
All reactions