{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/730","labels_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/730/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/730/comments","events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/730/events","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/730","id":110106177,"number":730,"title":"filter with related model's properties ","user":{"login":"FelipeAguayo","id":9990531,"avatar_url":"https://avatars.githubusercontent.com/u/9990531?v=3","gravatar_id":"","url":"https://api.github.com/users/FelipeAguayo","html_url":"https://github.com/FelipeAguayo","followers_url":"https://api.github.com/users/FelipeAguayo/followers","following_url":"https://api.github.com/users/FelipeAguayo/following{/other_user}","gists_url":"https://api.github.com/users/FelipeAguayo/gists{/gist_id}","starred_url":"https://api.github.com/users/FelipeAguayo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FelipeAguayo/subscriptions","organizations_url":"https://api.github.com/users/FelipeAguayo/orgs","repos_url":"https://api.github.com/users/FelipeAguayo/repos","events_url":"https://api.github.com/users/FelipeAguayo/events{/privacy}","received_events_url":"https://api.github.com/users/FelipeAguayo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/duplicate","name":"duplicate","color":"cccccc"},{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/triage","name":"triage","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-06T21:34:57Z","updated_at":"2015-10-14T21:57:07Z","closed_at":null,"body":"I have the following situation:\r\n\r\nModel:\r\n```json\r\n{\r\n  \"name\":\"Model\",\r\n  \"plural\":\"Models\",\r\n  \"idInjection\":true,\r\n  \"properties\":{\r\n     \"name\":\"string\"\r\n  },\r\n  \"relations\":{\r\n    \"relOtherModel\":{\r\n      \"type\": \"belongsTo\",\r\n      \"model\": \"OtherModel\",\r\n      \"foreignKey\": \"idOtherModel\"\r\n    }\r\n  }\r\n}\r\n```\r\nvalues Model: \r\n```js\r\n[ {id:1, idOtherModel:1, name:'one'}\r\n, {id:2, idOtherModel:1, name:'two'}\r\n, {id:3, idOtherModel:2, name:'three'}\r\n, {id:4, idOtherModel:3, name:'four'}]\r\n```\r\nOtherModel:\r\n```json\r\n{\r\n  \"name\":\"OtherModel\",\r\n  \"plural\":\"OtherModels\",\r\n  \"idInjection\":true,\r\n  \"properties\":{\r\n     \"name\":\"string\",\r\n     \"state\":\"string\"\r\n  }\r\n}\r\n```\r\nvalues OtherModel:\r\n```js\r\n[ {id:1, name:'otherOne', state: 'created'}\r\n, {id:2, name:'otherTwo', state: 'deleted'}\r\n, {id:3, name:'otherThree', state: 'created'}]\r\n```\r\n\r\nI want to get the values of \"Model 1\" that belong to \"OtherModel\" with state \"created\".\r\n\r\nExample: \r\n* [ GET ] http://localhost:3000/api/Models?filter={\"where\":{\"relOtherModel.state\":\"created\"}}\r\n* Model.find({where:{\"relOtherModel.state\":\"created\"}}, function(err, models){});\r\n* Other Solution.\r\n\r\nResult values:\r\n```js\r\n[ {id:1, idOtherModel:1, name:'one'}\r\n, {id:2, idOtherModel:1, name:'two'}\r\n, {id:4, idOtherModel:3, name:'four'}]\r\n```\r\nAny solution? :(\r\n\r\nPD: the query must be from Model."},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/comments/148214289","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/730#issuecomment-148214289","issue_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/730","id":148214289,"user":{"login":"superkhau","id":1617364,"avatar_url":"https://avatars.githubusercontent.com/u/1617364?v=3","gravatar_id":"","url":"https://api.github.com/users/superkhau","html_url":"https://github.com/superkhau","followers_url":"https://api.github.com/users/superkhau/followers","following_url":"https://api.github.com/users/superkhau/following{/other_user}","gists_url":"https://api.github.com/users/superkhau/gists{/gist_id}","starred_url":"https://api.github.com/users/superkhau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superkhau/subscriptions","organizations_url":"https://api.github.com/users/superkhau/orgs","repos_url":"https://api.github.com/users/superkhau/repos","events_url":"https://api.github.com/users/superkhau/events{/privacy}","received_events_url":"https://api.github.com/users/superkhau/received_events","type":"User","site_admin":false},"created_at":"2015-10-14T21:57:06Z","updated_at":"2015-10-14T21:57:06Z","body":"Thanks. I will mark this issue as a duplicate."}}