backbone-db
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -113,2 +113,3 @@ var Backbone = require('backbone'); | ||
}, | ||
create: function (model, options, cb) { | ||
@@ -135,5 +136,6 @@ debug('CREATE: ' + JSON.stringify(model)); | ||
}, | ||
find: function (model, options, cb) { | ||
debug("FIND: " + JSON.stringify(model)); | ||
this.store().getItem(model.get(model.idAttribute), function (err, data) { | ||
find: function(model, options, cb) { | ||
debug("FIND: "+JSON.stringify(model)); | ||
this.store().getItem(model.get(model.idAttribute), function(err, data) { | ||
data = data && JSON.parse(data); | ||
@@ -143,4 +145,5 @@ return cb(data ? null : new Error(), data); | ||
}, | ||
findAll: function (model, options, cb) { | ||
debug("FINDALL: " + JSON.stringify(model)); | ||
findAll: function(model, options, cb) { | ||
debug("FINDALL: "+JSON.stringify(model)); | ||
var self = this; | ||
@@ -166,2 +169,3 @@ var models = []; | ||
}, | ||
destroy: function (model, options, cb) { | ||
@@ -182,2 +186,3 @@ debug("DESTROY: " + JSON.stringify(model)); | ||
}, | ||
update: function (model, options, cb) { | ||
@@ -201,8 +206,11 @@ var self = this; | ||
}, | ||
createId: (function (id) { | ||
createId: (function(id) { | ||
return function (model, options, cb) { | ||
debug('createId: ' + id); | ||
if (model.createId) return model.createId(cb); | ||
debug('createId: '+id); | ||
cb(null, id++); | ||
}; | ||
})(1), | ||
inc: function (model, options, cb) { | ||
@@ -224,2 +232,3 @@ debug('INC:', options.inc); | ||
}, | ||
// expose "raw" storage backend. | ||
@@ -229,2 +238,3 @@ store: function () { | ||
}, | ||
sync: function (method, model, options) { | ||
@@ -271,2 +281,2 @@ options = options || {}; | ||
Db.sync = Db.prototype.sync; | ||
module.exports = Db; | ||
module.exports = Db; |
{ | ||
"name": "backbone-db", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Key-Value database storage interface, localStorage and in-process implementations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -82,3 +82,22 @@ var Db = require('../'); | ||
}); | ||
it('should override id creation function', function(t) { | ||
var ABCModel = MyModel.extend({ | ||
createId: function(callback) { | ||
callback(null, 'abc'); | ||
} | ||
}); | ||
var m = new ABCModel(); | ||
m.save(null, { | ||
success: function() { | ||
assert.equal(m.id, 'abc'); | ||
t(); | ||
}, | ||
error: function(err) { | ||
console.error(err); | ||
assert.ok(false); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19618
619
1