superfeedr/indexeddb-backbonejs-adapter — pull request #47 by amiuhle (2013-11-19 15:01:47+00:00)
Title: Compound indices

Added support for compound indices when fetching models. The index that matches most properties is chosen:

```javascript
store.createIndex("titleIndex", "title", { unique: false });
store.createIndex("formatIndex", "format", { unique: false });
store.createIndex("titleAndFormat", ["title", "format"], { unique: false });
```

`new Movie({ title: 'foo'}).fetch()` will use `titleIndex`, whereas `new Movie({ title: 'foo', format: 'bar'})` will use `titleAndFormat`. If there is no `titleAndFormat` index, but you supply both properties, the behavior is unchanged, eg the first matching index is chosen.
If you supply additional properties, for example `new Movie({ title: 'foo', format: 'bar', 'rating': 4.5 })`, `titleAndFormat` will be chosen because it matches more properties than either `titleIndex` or `formatIndex`.

I also added an option to supply index information in the options:
```javascript
var movie = new Movie();
movie.fetch({
index: {
name: 'titleAndFormat',
value: ['Django Unchained', 'blueray']
}
});
```