backbone-db-redis
Advanced tools
Comparing version 0.0.35 to 0.0.36
@@ -381,5 +381,8 @@ var _ = require('lodash'), | ||
var params = _.clone(options.indexKeys); | ||
if (collection.indexSort) params.unshift(options.indexKeys.length); // how many keys to union | ||
if (collection.indexSort) params.unshift(options.indexKeys.length); // how many sets to union | ||
params.unshift(unionKey); // where to store | ||
if (options.weights) { | ||
params.push('WEIGHTS'); | ||
params.push.apply(params, options.weights); | ||
} | ||
var unionFn = collection.indexSort ? | ||
@@ -386,0 +389,0 @@ _.bind(this.redis.zunionstore, this.redis) : |
{ | ||
"name": "backbone-db-redis", | ||
"version": "0.0.35", | ||
"version": "0.0.36", | ||
"description": "Redis driver for Backbone.Db", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -46,2 +46,3 @@ var assert = require('assert'); | ||
options.unionKey = this.unionKey || options.unionKey; | ||
if (this.indexKey) options.indexKeys.push(this.indexKey); | ||
var args = [this, options]; | ||
@@ -239,2 +240,25 @@ return nodefn.apply(_.bind(this.indexDb.readFromIndexes, this.indexDb), args); | ||
it('should read from multiple indexes with weights', function() { | ||
var opts = { | ||
indexKeys: ['test:i:Foo:relation'], | ||
unionKey: 'test:i:UnionFoo', | ||
weights: [1, 10], | ||
score: { | ||
conversion: { | ||
fn: function(score) { | ||
return score; | ||
}, | ||
attribute: 'score' | ||
} | ||
} | ||
}; | ||
collection2 = new TestCollection2(); | ||
return collection2 | ||
.readFromIndexes(opts) | ||
.then(function() { | ||
assert.equal(collection2.length, 4); | ||
collection2.at(0).id.should.equal('4'); | ||
}); | ||
}); | ||
it('should fetch models', function(done) { | ||
@@ -277,2 +301,3 @@ var fetchOpts = { | ||
/* | ||
it('should remove model from index', function(done) { | ||
@@ -311,4 +336,4 @@ var model = collection.at(0); | ||
}).otherwise(done); | ||
}); | ||
});*/ | ||
}); |
61004
1801