loopbackjs - HasAndBelongsToMany symmetric query -


i trying figure out how use hasandbelongstomany relation simple case. example have 2 models, person (derived user) , someobject (derived persistentmodel).

now when add relation someobject -> hasandbelongstomany -> person (let call rela) can example do

put /someobject/{id}/rela/{fk} 

this creates joined model someobjectperson. cannot query someobjects given id of person.

i have looked examples , of them create relation other direction (let's call rela2) person -> hasandbelongstomany -> someobject. not understand why, since relation name suggests symmetrical nature.

but if , perform a

put /person/{id}/rela2/{fk} 

another joined model created disjoint data. additionally queries in 1 direction return values added in respective direction.

i guess through-model help, far can tell whole idea of relation rid of (visible) through models consisting of (foreign) ids. not mention can't tell semantic difference between hasandbelongstomany or hasmany...

hope can enlighten me.

best, richard


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -