{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1524","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1524/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1524/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1524/events","html_url":"https://github.com/strongloop/loopback/issues/1524","id":95263281,"number":1524,"title":"multiple hasMany through relations to same model","user":{"login":"Silvercast","id":998048,"avatar_url":"https://avatars.githubusercontent.com/u/998048?v=3","gravatar_id":"","url":"https://api.github.com/users/Silvercast","html_url":"https://github.com/Silvercast","followers_url":"https://api.github.com/users/Silvercast/followers","following_url":"https://api.github.com/users/Silvercast/following{/other_user}","gists_url":"https://api.github.com/users/Silvercast/gists{/gist_id}","starred_url":"https://api.github.com/users/Silvercast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Silvercast/subscriptions","organizations_url":"https://api.github.com/users/Silvercast/orgs","repos_url":"https://api.github.com/users/Silvercast/repos","events_url":"https://api.github.com/users/Silvercast/events{/privacy}","received_events_url":"https://api.github.com/users/Silvercast/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-15T18:44:45Z","updated_at":"2015-08-30T18:42:01Z","closed_at":null,"body":"Hi,\r\nI'm trying to modelize a graph of nodes. One node has many parent nodes. it can also have many sub nodes. I'm quite new to loopback so I use JSON files to define models.\r\n\r\nin `node.json` I define\r\n\r\n```\r\n   \"subnodes\": {\r\n      \"type\": \"hasMany\",\r\n      \"model\": \"Node\",\r\n      \"foreignKey\": \"idparent\",\r\n      \"through\": \"NodeRelation\"\r\n    },\r\n    \"parentnodes\": {\r\n      \"type\": \"hasMany\",\r\n      \"model\": \"Node\",\r\n      \"foreignKey\": \"idchild\",\r\n      \"through\": \"NodeRelation\"\r\n    }\r\n```\r\n\r\nin `noderelation.json` I define \r\n```\r\n\"relations\": {\r\n    \"node\": {\r\n      \"type\": \"belongsTo\",\r\n      \"model\": \"Node\",\r\n      \"foreignKey\": \"idparent\"\r\n    },\r\n    \"node\": {\r\n      \"type\": \"belongsTo\",\r\n      \"model\": \"Node\",\r\n      \"foreignKey\": \"idchild\"\r\n    }\r\n  }\r\n```\r\n\r\nI can query sub nodes but parent nodes return incorrect results. If I change duplicated `node` relations to something like `parent`, `child` I get error 500, `node` relation is not defined in NodeRelation model.\r\n\r\nAny hint? I really appreciate your helps. "},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/136174322","html_url":"https://github.com/strongloop/loopback/issues/1524#issuecomment-136174322","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1524","id":136174322,"user":{"login":"jewelsjacobs","id":3187525,"avatar_url":"https://avatars.githubusercontent.com/u/3187525?v=3","gravatar_id":"","url":"https://api.github.com/users/jewelsjacobs","html_url":"https://github.com/jewelsjacobs","followers_url":"https://api.github.com/users/jewelsjacobs/followers","following_url":"https://api.github.com/users/jewelsjacobs/following{/other_user}","gists_url":"https://api.github.com/users/jewelsjacobs/gists{/gist_id}","starred_url":"https://api.github.com/users/jewelsjacobs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jewelsjacobs/subscriptions","organizations_url":"https://api.github.com/users/jewelsjacobs/orgs","repos_url":"https://api.github.com/users/jewelsjacobs/repos","events_url":"https://api.github.com/users/jewelsjacobs/events{/privacy}","received_events_url":"https://api.github.com/users/jewelsjacobs/received_events","type":"User","site_admin":false},"created_at":"2015-08-30T18:42:01Z","updated_at":"2015-08-30T18:42:01Z","body":"I have the same need to do this. I have a group model with a oneToMany relationship to subgroups with the same model. Any advice?"}}