backbone-db
Advanced tools
Comparing version 0.4.13 to 0.4.15
@@ -240,5 +240,10 @@ var Backbone = require('backbone'); | ||
this.store().getItem(id, function(err, data) { | ||
data = data || '{}'; | ||
data = JSON.parse(data); | ||
_.merge(data, model.toJSON(options)); | ||
data = data && JSON.parse(data); | ||
var modelData = model.toJSON(options); | ||
// Support for non plain object JSON types. | ||
if(_.isPlainObject(data) && _.isPlainObject(modelData)) { | ||
_.merge(data, modelData); | ||
} else { | ||
data = modelData; | ||
} | ||
self.store().setItem(id, JSON.stringify(data), function (err, res) { | ||
@@ -309,4 +314,4 @@ // if models created with id. | ||
} | ||
debug('sync %s %s', method, JSON.stringify(options)); | ||
debug('sync %s %s %s %s', method, model.type, JSON.stringify(model.toJSON(options)), JSON.stringify(options)); | ||
if(model.type === 'video' && method === 'update') console.log(new Error().stack); | ||
function callback(err, res, resp) { | ||
@@ -313,0 +318,0 @@ debug('callback ' + err + ' ' + JSON.stringify(res)); |
{ | ||
"name": "backbone-db", | ||
"version": "0.4.13", | ||
"version": "0.4.15", | ||
"description": "Key-Value database storage interface, localStorage and in-process implementations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
163645
939