{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1319","repository_url":"https://api.github.com/repos/strongloop/loopback","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1319/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1319/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1319/events","html_url":"https://github.com/strongloop/loopback/issues/1319","id":69669015,"number":1319,"title":"Use Include filter to get polymorphic belongsTo relation","user":{"login":"zane-insta","id":11557309,"avatar_url":"https://avatars.githubusercontent.com/u/11557309?v=3","gravatar_id":"","url":"https://api.github.com/users/zane-insta","html_url":"https://github.com/zane-insta","followers_url":"https://api.github.com/users/zane-insta/followers","following_url":"https://api.github.com/users/zane-insta/following{/other_user}","gists_url":"https://api.github.com/users/zane-insta/gists{/gist_id}","starred_url":"https://api.github.com/users/zane-insta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zane-insta/subscriptions","organizations_url":"https://api.github.com/users/zane-insta/orgs","repos_url":"https://api.github.com/users/zane-insta/repos","events_url":"https://api.github.com/users/zane-insta/events{/privacy}","received_events_url":"https://api.github.com/users/zane-insta/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback/labels/triage","name":"triage","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-04-20T20:08:38Z","updated_at":"2016-04-13T18:01:25Z","closed_at":null,"body":"Hi,\r\n\r\nI have a polymorphic comment model that can belong to several other models. I want to be able to query the comment and include the parent model that it belongs to.\r\nI have my comment model defined below.\r\n\r\n```\r\n{\r\n  \"name\": \"comment\",\r\n  \"validations\": [],\r\n  \"relations\": {\r\n    \"commentable\": {\r\n      \"type\": \"belongsTo\",\r\n      \"polymorphic\": true\r\n    },\r\n...\r\n```\r\n\r\nI am trying to query it by calling ...\r\n```\r\nvar filter = {\r\n   include: {\r\n      relation: 'commentable'\r\n   }  \r\n}; \r\n\r\nComment.findById({id: notification.parentId, filter: filter})\r\n.$promise\r\n.then(function(res) {\r\n   console.log('Result: ' + res);\r\n});\r\n```\r\n\r\nI receive the comment back fine but the commentable type is not retrieved properly.\r\nI dug into the debug logs and I believe there is a bug somewhere because when it queries the database for the related model it says\r\n```\r\nall +0ms myModel { where: { id: 1}, limit: 1, offset: 0, skip: 0 }\r\n```\r\nbut it should be asking for \r\n```\r\nall +0ms myModel { where: { myId: 1}, limit: 1, offset: 0, skip: 0 }\r\n```\r\nsince I have a custom id member named myId instead of the default id."},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/209570397","html_url":"https://github.com/strongloop/loopback/issues/1319#issuecomment-209570397","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1319","id":209570397,"user":{"login":"loay","id":1986928,"avatar_url":"https://avatars.githubusercontent.com/u/1986928?v=3","gravatar_id":"","url":"https://api.github.com/users/loay","html_url":"https://github.com/loay","followers_url":"https://api.github.com/users/loay/followers","following_url":"https://api.github.com/users/loay/following{/other_user}","gists_url":"https://api.github.com/users/loay/gists{/gist_id}","starred_url":"https://api.github.com/users/loay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loay/subscriptions","organizations_url":"https://api.github.com/users/loay/orgs","repos_url":"https://api.github.com/users/loay/repos","events_url":"https://api.github.com/users/loay/events{/privacy}","received_events_url":"https://api.github.com/users/loay/received_events","type":"User","site_admin":false},"created_at":"2016-04-13T18:01:25Z","updated_at":"2016-04-13T18:01:25Z","body":"@zanemcca \r\nSorry the tag mention goes directly to the name you used to open the issue. \r\nI am having another look. thanks for clarifying. \r\n"}}