{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/1310","repository_url":"https://api.github.com/repos/balderdashy/waterline","labels_url":"https://api.github.com/repos/balderdashy/waterline/issues/1310/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/1310/comments","events_url":"https://api.github.com/repos/balderdashy/waterline/issues/1310/events","html_url":"https://github.com/balderdashy/waterline/pull/1310","id":135000598,"number":1310,"title":"Projections","user":{"login":"particlebanana","id":370260,"avatar_url":"https://avatars.githubusercontent.com/u/370260?v=3","gravatar_id":"","url":"https://api.github.com/users/particlebanana","html_url":"https://github.com/particlebanana","followers_url":"https://api.github.com/users/particlebanana/followers","following_url":"https://api.github.com/users/particlebanana/following{/other_user}","gists_url":"https://api.github.com/users/particlebanana/gists{/gist_id}","starred_url":"https://api.github.com/users/particlebanana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particlebanana/subscriptions","organizations_url":"https://api.github.com/users/particlebanana/orgs","repos_url":"https://api.github.com/users/particlebanana/repos","events_url":"https://api.github.com/users/particlebanana/events{/privacy}","received_events_url":"https://api.github.com/users/particlebanana/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/balderdashy/waterline/labels/feature","name":"feature","color":"c7def8"},{"url":"https://api.github.com/repos/balderdashy/waterline/labels/proposal","name":"proposal","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-02-19T23:23:52Z","updated_at":"2016-05-02T20:01:46Z","closed_at":"2016-03-17T21:57:47Z","pull_request":{"url":"https://api.github.com/repos/balderdashy/waterline/pulls/1310","html_url":"https://github.com/balderdashy/waterline/pull/1310","diff_url":"https://github.com/balderdashy/waterline/pull/1310.diff","patch_url":"https://github.com/balderdashy/waterline/pull/1310.patch"},"body":"### DO NOT MERGE\r\n\r\nThis PR represents the initial work for projections on both the parent and child criteria. It finally brings official support for `select` and adds a `.select()` method to the deferred object. It also adds support for using `select` inside of criteria in a `populate`. \r\n\r\nOne thing to note is that any primary keys and foreign keys used in a join will always be selected. This is unavoidable due to the way we currently build up join queries and combine results in cross-adapter populates.\r\n\r\nThe first thing that needs to happen is tests in [Waterline Adapter Tests](https://github.com/balderdashy/waterline-adapter-tests) to ensure things won't break across the officially supported adapters. There is a corresponding PR in [Waterline Sequel](https://github.com/balderdashy/waterline-sequel/pull/80) that needs to be brought in for the SQL adapters and I'm sure there will be some slight tweaks that need to happen in the Mongo adapter.\r\n\r\n**Example Use:**\r\n\r\n```javascript\r\n// Deferred Object Style\r\nUser.find()\r\n.select(['name', 'age'])\r\n.where({\r\n  age: {\r\n    '>': 21\r\n  }\r\n})\r\n.exec(function(err, users) {});\r\n```\r\n\r\n```javascript\r\n// Populate projections\r\nUser.find()\r\n.select(['name', 'age'])\r\n.populate('pets', { select: ['breed', 'name'] })\r\n.exec(function(err, users) {});\r\n```\r\n\r\n```javascript\r\n// Callback style\r\nUser.find({ select: ['name', 'age'] }, function(err, users) {});\r\n```"},"comment":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/comments/216345749","html_url":"https://github.com/balderdashy/waterline/pull/1310#issuecomment-216345749","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/1310","id":216345749,"user":{"login":"particlebanana","id":370260,"avatar_url":"https://avatars.githubusercontent.com/u/370260?v=3","gravatar_id":"","url":"https://api.github.com/users/particlebanana","html_url":"https://github.com/particlebanana","followers_url":"https://api.github.com/users/particlebanana/followers","following_url":"https://api.github.com/users/particlebanana/following{/other_user}","gists_url":"https://api.github.com/users/particlebanana/gists{/gist_id}","starred_url":"https://api.github.com/users/particlebanana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particlebanana/subscriptions","organizations_url":"https://api.github.com/users/particlebanana/orgs","repos_url":"https://api.github.com/users/particlebanana/repos","events_url":"https://api.github.com/users/particlebanana/events{/privacy}","received_events_url":"https://api.github.com/users/particlebanana/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T20:01:46Z","updated_at":"2016-05-02T20:01:46Z","body":"@luislobo we should add some [tests](https://github.com/balderdashy/waterline-adapter-tests/blob/master/interfaces/queryable/projections.test.js) for those cases first. But that sounds good."}}