hasAndBelongsToMany self-relation

73 views
Skip to first unread message

Itay Shoshani

unread,
Jul 20, 2016, 8:03:40 AM7/20/16
to LoopbackJS
Hello, I've seen this question and I have the exact same issue:
https://github.com/strongloop/loopback/issues/537

My question is almost identical to the question that were asked in the link:
I have Article model which has related_articles in it, when one article 1 is related to article 2, article 2 must be related to article 1 as well.

this structure is a bit similar to facebook friends, if someone is my friend, therefore I'm his friend too. Is that possible to do with loopback's relation system?

thank you.

yotam shalev

unread,
Aug 1, 2016, 3:37:17 AM8/1/16
to LoopbackJS
Hi Itay, 
I have the same issue. Did you find a solution?
Message has been deleted

aquid raza rahman

unread,
Aug 1, 2016, 5:10:35 AM8/1/16
to LoopbackJS
Hi,

You should be using HasMany thorugh relation for self relationship, but there's a tweak for that. You might have to add an extra parameter named as `keyThrough ` for self referencing.

You can see the example here: 

Thanks
Reply all
Reply to author
Forward
0 new messages