{"action":"created","issue":{"url":"https://api.github.com/repos/js-data/js-data-rethinkdb/issues/7","labels_url":"https://api.github.com/repos/js-data/js-data-rethinkdb/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/js-data/js-data-rethinkdb/issues/7/comments","events_url":"https://api.github.com/repos/js-data/js-data-rethinkdb/issues/7/events","html_url":"https://github.com/js-data/js-data-rethinkdb/issues/7","id":64561635,"number":7,"title":"Support secondary indices in findAll","user":{"login":"jmdobry","id":1213510,"avatar_url":"https://avatars.githubusercontent.com/u/1213510?v=3","gravatar_id":"","url":"https://api.github.com/users/jmdobry","html_url":"https://github.com/jmdobry","followers_url":"https://api.github.com/users/jmdobry/followers","following_url":"https://api.github.com/users/jmdobry/following{/other_user}","gists_url":"https://api.github.com/users/jmdobry/gists{/gist_id}","starred_url":"https://api.github.com/users/jmdobry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmdobry/subscriptions","organizations_url":"https://api.github.com/users/jmdobry/orgs","repos_url":"https://api.github.com/users/jmdobry/repos","events_url":"https://api.github.com/users/jmdobry/events{/privacy}","received_events_url":"https://api.github.com/users/jmdobry/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/js-data/js-data-rethinkdb/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-03-26T15:44:06Z","updated_at":"2015-07-21T18:10:27Z","closed_at":null,"body":"Example:\r\n```js\r\nadapter.findAll(User, {\r\n  where: {\r\n    age: { '>': 30 },\r\n    status: 'unknown'\r\n  }\r\n});\r\n```\r\n\r\nLet's say there is a secondary index setup on the \"status\" field. In order to tell the query to take advantage of this, I propose the following:\r\n\r\n```js\r\nadapter.findAll(User, {\r\n  where: {\r\n    age: { '>': 30 },\r\n    status: { '==': 'unknown' }\r\n  }\r\n}, {\r\n  keys: ['status']\r\n});\r\n```\r\n\r\nWhich will optimize the query by first doing a `getAll('unknown', { index: 'status' })` and then adding the `filter` calls."},"comment":{"url":"https://api.github.com/repos/js-data/js-data-rethinkdb/issues/comments/123419757","html_url":"https://github.com/js-data/js-data-rethinkdb/issues/7#issuecomment-123419757","issue_url":"https://api.github.com/repos/js-data/js-data-rethinkdb/issues/7","id":123419757,"user":{"login":"internalfx","id":583701,"avatar_url":"https://avatars.githubusercontent.com/u/583701?v=3","gravatar_id":"","url":"https://api.github.com/users/internalfx","html_url":"https://github.com/internalfx","followers_url":"https://api.github.com/users/internalfx/followers","following_url":"https://api.github.com/users/internalfx/following{/other_user}","gists_url":"https://api.github.com/users/internalfx/gists{/gist_id}","starred_url":"https://api.github.com/users/internalfx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/internalfx/subscriptions","organizations_url":"https://api.github.com/users/internalfx/orgs","repos_url":"https://api.github.com/users/internalfx/repos","events_url":"https://api.github.com/users/internalfx/events{/privacy}","received_events_url":"https://api.github.com/users/internalfx/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T18:10:27Z","updated_at":"2015-07-21T18:10:27Z","body":"wow, didn't know this was here."}}