backbone-db-redis
Advanced tools
Comparing version 0.0.8 to 0.0.9
14
index.js
@@ -1,8 +0,8 @@ | ||
var _ = require('underscore') | ||
, Backbone = require('backbone') | ||
, Db = require('backbone-db') | ||
, redis = require('redis') | ||
, debug = require('debug')('backbone-db-redis') | ||
, indexing = require('./lib/indexing') | ||
, query = require('./lib/query'); | ||
var _ = require('underscore'), | ||
Backbone = require('backbone'), | ||
Db = require('backbone-db'), | ||
redis = require('redis'), | ||
debug = require('debug')('backbone-db-redis'), | ||
indexing = require('./lib/indexing'), | ||
query = require('./lib/query'); | ||
@@ -9,0 +9,0 @@ |
@@ -126,3 +126,3 @@ var Deferred = require('backbone-promises'); | ||
cb(null, self); | ||
}) | ||
}); | ||
}); | ||
@@ -158,2 +158,2 @@ }, | ||
} | ||
}) | ||
}); |
@@ -64,2 +64,2 @@ var Deferred = require('backbone-promises'); | ||
} | ||
}) | ||
}); |
@@ -1,4 +0,4 @@ | ||
var redis = require('redis') | ||
, debug = require('debug')('store') | ||
, _ = require('underscore'); | ||
var redis = require('redis'), | ||
debug = require('debug')('store'), | ||
_ = require('underscore'); | ||
@@ -38,2 +38,2 @@ /** | ||
module.exports = RedisStore; | ||
module.exports = RedisStore; |
@@ -6,3 +6,3 @@ var Deferred = require('backbone-promises'); | ||
var Set = module.exports = Deferred.Collection.extend({ | ||
module.exports = Deferred.Collection.extend({ | ||
constructor: function() { | ||
@@ -35,8 +35,9 @@ Deferred.Collection.apply(this, arguments); | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
opt = opt || {}; | ||
return this.defer('sinter', opt, function(cb) { | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
var src = db.key(self.url()); | ||
@@ -46,3 +47,3 @@ var dst = db.key(collection.url()); | ||
db.redis.sinter(src, dst, function(err, ids) { | ||
if(err || (!ids || ids.length == 0)) { | ||
if(err || (!ids || ids.length === 0)) { | ||
return cb(err, ids); | ||
@@ -52,3 +53,3 @@ } | ||
ids.forEach(function(id) { | ||
var model = new self.model({id:id}) | ||
var model = new self.model({id:id}); | ||
self.add(model); | ||
@@ -66,7 +67,6 @@ debug('fetching %s',id); | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
return this.defer('smove', function(cb) { | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
var src = db.key(self.url()); | ||
@@ -90,7 +90,7 @@ var dst = db.key(collection.url()); | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
return this.defer('sunion', opt, function(cb) { | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
return this.defer('sunion', opt, function(cb) { | ||
var src = db.key(self.url()); | ||
@@ -100,3 +100,3 @@ var dst = db.key(collection.url()); | ||
db.redis.sunion(src, dst, function(err, ids) { | ||
if(err || (!ids || ids.length == 0)) { | ||
if(err || (!ids || ids.length === 0)) { | ||
return cb(err, ids); | ||
@@ -106,3 +106,3 @@ } | ||
ids.forEach(function(id) { | ||
var model = new self.model({id:id}) | ||
var model = new self.model({id:id}); | ||
self.add(model); | ||
@@ -135,11 +135,11 @@ debug('fetching %s',id); | ||
}, | ||
sdiff: function() { | ||
sdiff: function(collection, opt) { | ||
var self = this, | ||
db = this.db || this.model.db; | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
return this.defer('sdiff', function(cb) { | ||
return this.defer('sdiff', opt, function(cb) { | ||
if(!self.url || !collection.url) { | ||
return cb(new Error("url function is required for source and destination collections")); | ||
} | ||
var src = db.key(self.url()); | ||
@@ -149,3 +149,3 @@ var dst = db.key(collection.url()); | ||
db.redis.sdiff(src, dst, function(err, ids) { | ||
if(err || (!ids || ids.length == 0)) { | ||
if(err || (!ids || ids.length === 0)) { | ||
return cb(err, ids); | ||
@@ -155,3 +155,3 @@ } | ||
ids.forEach(function(id) { | ||
var model = new self.model({id:id}) | ||
var model = new self.model({id:id}); | ||
self.add(model); | ||
@@ -226,2 +226,2 @@ debug('fetching %s',id); | ||
} | ||
}); | ||
}); |
{ | ||
"name": "backbone-db-redis", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Redis driver for Backbone.Db", | ||
@@ -17,9 +17,12 @@ "main": "index.js", | ||
"debug": "~0.7.2", | ||
"backbone-db": "~0.3.0", | ||
"backbone-promises": "~0.1.8", | ||
"backbone-db": "~0.4.0", | ||
"backbone-promises": "~0.2.0", | ||
"when": "~2.7.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.15.1" | ||
"mocha": "~1.15.1", | ||
"istanbul": "~0.2.4", | ||
"chai": "~1.9.0", | ||
"jshint": "~2.4.3" | ||
} | ||
} |
## Usage | ||
[![Build Status](https://travis-ci.org/Everyplay/backbone-db-redis.png?branch=master)](https://travis-ci.org/Everyplay/backbone-db-redis) | ||
```js | ||
@@ -70,2 +70,2 @@ | ||
If defined, store index in given set key, otherwise created automatically. | ||
If defined, store index in given set key, otherwise created automatically. |
Sorry, the diff of this file is not supported yet
373824
34
1876
71
4
+ Addedbackbone-db@0.4.25(transitive)
+ Addedbackbone-promises@0.2.9(transitive)
+ Addedbackdash@1.1.2-2.4.1(transitive)
+ Addeddebug@0.8.11.0.5(transitive)
+ Addedlodash@2.4.1(transitive)
+ Addedms@2.0.0(transitive)
+ Addedwhen@3.7.8(transitive)
- Removedbackbone-db@0.3.4(transitive)
- Removedbackbone-promises@0.1.8(transitive)
- Removedwhen@2.4.0(transitive)
Updatedbackbone-db@~0.4.0
Updatedbackbone-promises@~0.2.0