{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/281","labels_url":"https://api.github.com/repos/balderdashy/waterline/issues/281/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/281/comments","events_url":"https://api.github.com/repos/balderdashy/waterline/issues/281/events","html_url":"https://github.com/balderdashy/waterline/issues/281","id":28147290,"number":281,"title":"Query based on association value","user":{"login":"ndhoule","id":1863990,"avatar_url":"https://avatars.githubusercontent.com/u/1863990?v=3","gravatar_id":"","url":"https://api.github.com/users/ndhoule","html_url":"https://github.com/ndhoule","followers_url":"https://api.github.com/users/ndhoule/followers","following_url":"https://api.github.com/users/ndhoule/following{/other_user}","gists_url":"https://api.github.com/users/ndhoule/gists{/gist_id}","starred_url":"https://api.github.com/users/ndhoule/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndhoule/subscriptions","organizations_url":"https://api.github.com/users/ndhoule/orgs","repos_url":"https://api.github.com/users/ndhoule/repos","events_url":"https://api.github.com/users/ndhoule/events{/privacy}","received_events_url":"https://api.github.com/users/ndhoule/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-02-24T09:23:13Z","updated_at":"2015-08-22T18:05:01Z","closed_at":"2014-02-28T00:46:02Z","body":"[This StackOverflow post](https://stackoverflow.com/questions/19489017/rails-activerecord-query-based-on-association-value) summarizes what I'm about to talk about, perhaps a bit more succinctly.\r\n\r\nIs there a way to query a model based on values contained in an association? Basically, something like this:\r\n\r\n```javascript\r\n// api/models/User.js\r\nmodule.exports = {\r\n  attributes: {\r\n    username: {\r\n      type: 'string',\r\n      required: true,\r\n    },\r\n\r\n    assignments: {\r\n      collection: 'profile',\r\n      via: 'user',\r\n      dominant: true,\r\n    }\r\n  }\r\n};\r\n\r\n// api/models/Profile.js\r\nmodule.exports = {\r\n  attributes: {\r\n    users: {\r\n      collection: 'user',\r\n      via: 'assignments'\r\n    }\r\n  }\r\n};\r\n\r\n// Consumption code\r\nAssignment.find()\r\n  .populate('users')\r\n  .where({\r\n    'users.username': 'ndhoule'\r\n  })\r\n  .exec(/* ... */)\r\n```\r\n\r\nI get the impression this hasn't yet been implemented, but didn't see another issue."},"comment":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/comments/133736309","html_url":"https://github.com/balderdashy/waterline/issues/281#issuecomment-133736309","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/281","id":133736309,"user":{"login":"dmarcelino","id":1280446,"avatar_url":"https://avatars.githubusercontent.com/u/1280446?v=3","gravatar_id":"","url":"https://api.github.com/users/dmarcelino","html_url":"https://github.com/dmarcelino","followers_url":"https://api.github.com/users/dmarcelino/followers","following_url":"https://api.github.com/users/dmarcelino/following{/other_user}","gists_url":"https://api.github.com/users/dmarcelino/gists{/gist_id}","starred_url":"https://api.github.com/users/dmarcelino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmarcelino/subscriptions","organizations_url":"https://api.github.com/users/dmarcelino/orgs","repos_url":"https://api.github.com/users/dmarcelino/repos","events_url":"https://api.github.com/users/dmarcelino/events{/privacy}","received_events_url":"https://api.github.com/users/dmarcelino/received_events","type":"User","site_admin":false},"created_at":"2015-08-22T18:05:01Z","updated_at":"2015-08-22T18:05:01Z","body":"Hi @gaurav21r, please track #266 which this issue duplicates. It's also better to keep the discussion there."}}