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:
var movie = new Movie();
movie.fetch({
index: {
name: 'titleAndFormat',
value: ['Django Unchained', 'blueray']
}
});
Added support for compound indices when fetching models. The index that matches most properties is chosen:
new Movie({ title: 'foo'}).fetch()
will usetitleIndex
, whereasnew Movie({ title: 'foo', format: 'bar'})
will usetitleAndFormat
. If there is notitleAndFormat
index, but you supply both properties, the behavior is unchanged, eg the first matching index is chosen. If you supply additional properties, for examplenew Movie({ title: 'foo', format: 'bar', 'rating': 4.5 })
,titleAndFormat
will be chosen because it matches more properties than eithertitleIndex
orformatIndex
.I also added an option to supply index information in the options: