{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/266","labels_url":"https://api.github.com/repos/balderdashy/waterline/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/266/comments","events_url":"https://api.github.com/repos/balderdashy/waterline/issues/266/events","html_url":"https://github.com/balderdashy/waterline/issues/266","id":27198339,"number":266,"title":"Need a way to query associated object's attributes","user":{"login":"gregorypierce","id":95954,"avatar_url":"https://avatars.githubusercontent.com/u/95954?v=3","gravatar_id":"","url":"https://api.github.com/users/gregorypierce","html_url":"https://github.com/gregorypierce","followers_url":"https://api.github.com/users/gregorypierce/followers","following_url":"https://api.github.com/users/gregorypierce/following{/other_user}","gists_url":"https://api.github.com/users/gregorypierce/gists{/gist_id}","starred_url":"https://api.github.com/users/gregorypierce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregorypierce/subscriptions","organizations_url":"https://api.github.com/users/gregorypierce/orgs","repos_url":"https://api.github.com/users/gregorypierce/repos","events_url":"https://api.github.com/users/gregorypierce/events{/privacy}","received_events_url":"https://api.github.com/users/gregorypierce/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/balderdashy/waterline/labels/feature","name":"feature","color":"207de5"},{"url":"https://api.github.com/repos/balderdashy/waterline/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/balderdashy/waterline/milestones/10","html_url":"https://github.com/balderdashy/waterline/milestones/WL_Next","labels_url":"https://api.github.com/repos/balderdashy/waterline/milestones/10/labels","id":1073336,"number":10,"title":"WL_Next","description":"Post 0.11 release, maybe 0.12 or 1.0.0.","creator":{"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},"open_issues":6,"closed_issues":0,"state":"open","created_at":"2015-04-18T15:54:04Z","updated_at":"2015-04-20T14:48:13Z","due_on":null,"closed_at":null},"comments":11,"created_at":"2014-02-08T10:54:36Z","updated_at":"2015-06-15T08:57:42Z","closed_at":null,"body":"If an object has an associated collection, it is not clear how (or even if its possible) to query into that associated object stuff.\r\n\r\nPet has an Owner\r\nOwner has an emailAddress\r\n\r\nHow do I select all of the Pets whose owner has an `emailAddress == \"foo@bar.com\"`\r\n\r\nWhile its easy to do 2 queries to accomplish this:\r\n1) Find the owner who has an `emailAddress == \"foo@bar.com\"` and get that persons `id`\r\n2) Find all Pets who have the `id` from query 1\r\n\r\nIt seems that there would be a better syntax for this:\r\n\r\n```javascript\r\nPet.findAll({ \"owner.emailAddress\" : \"foo@bar.com\" })\r\n```\r\n\r\nNow whether or not this is internally optimized or just syntactic sugar doesn't matter, its much easier to read and write.\r\n\r\nFurther, if a Pet has a breed how would I select the email addresses of all of the owners whose `Pet.breed == \"beagle\"`\r\n\r\n```javascript\r\nOwner.findAll({\"pet.breed\" : \"beagle\"})\r\n```"},"comment":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/comments/111984170","html_url":"https://github.com/balderdashy/waterline/issues/266#issuecomment-111984170","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/266","id":111984170,"user":{"login":"atiertant","id":6105084,"avatar_url":"https://avatars.githubusercontent.com/u/6105084?v=3","gravatar_id":"","url":"https://api.github.com/users/atiertant","html_url":"https://github.com/atiertant","followers_url":"https://api.github.com/users/atiertant/followers","following_url":"https://api.github.com/users/atiertant/following{/other_user}","gists_url":"https://api.github.com/users/atiertant/gists{/gist_id}","starred_url":"https://api.github.com/users/atiertant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atiertant/subscriptions","organizations_url":"https://api.github.com/users/atiertant/orgs","repos_url":"https://api.github.com/users/atiertant/repos","events_url":"https://api.github.com/users/atiertant/events{/privacy}","received_events_url":"https://api.github.com/users/atiertant/received_events","type":"User","site_admin":false},"created_at":"2015-06-15T08:57:42Z","updated_at":"2015-06-15T08:57:42Z","body":"we are thinking about adding this in deep populate (when merged) https://github.com/balderdashy/waterline/pull/1052\r\n@particlebanana @devinivy filter results was our first idea but takes a lot of memory... this could be solved by doing something like this : \r\nwith the previous exemple:\r\n\r\n    Owner.findAll([{\"pet.breed\": \"beagle\"}, {billingMethod: \"visa\"}, {vet.state: \"GA\"}])\r\n\r\nshould become:\r\n\r\n    vet.findAll({select:['Owner_id'],state: \"GA\"})         // => [55,56,57,58,80]\r\n    pet.findAll({select:['Owner_id'],breed: \"beagle\"})   // => [25,32,57,58,205]\r\n\r\n    Owner.findAll(id : [57,58],billingMethod: \"visa\"})\r\n\r\nwhat do you think about this solution ? have you got a better one?"}}