Comparing version 0.3.0 to 0.3.1
29
index.js
@@ -31,8 +31,10 @@ var _ = require('underscore'); | ||
if (!err) { | ||
return success(doc); | ||
success(model, doc, options); | ||
} | ||
if (err.error === 'not_found' && model.allowMissing) { | ||
return success({}); | ||
else if (err.error === 'not_found' && model.allowMissing) { | ||
success(model, {}, options); | ||
} | ||
error(err); | ||
else { | ||
error(err); | ||
} | ||
}); | ||
@@ -44,3 +46,8 @@ break; | ||
db.insert(model.toJSON(), function(err, res) { | ||
err ? error(err) : success({ _id: res.id, _rev: res.rev }); | ||
if (err) { | ||
error(model, err, options); | ||
} | ||
else { | ||
success(model, { _id: res.id, _rev: res.rev }, options); | ||
} | ||
}); | ||
@@ -51,3 +58,8 @@ break; | ||
db.destroy(model.id, model.get('_rev'), function(err, res) { | ||
err ? error(err) : success({ _id: res.id, _rev: res.rev }); | ||
if (err) { | ||
error(model, err, options); | ||
} | ||
else { | ||
success(model, { _id: res.id, _rev: res.rev }, options); | ||
} | ||
}); | ||
@@ -85,3 +97,6 @@ break; | ||
model.read(db, function(err, res) { | ||
err ? error(err) : success(res); | ||
if (err) | ||
error(model, err, options); | ||
else | ||
success(model, res, options); | ||
}); | ||
@@ -88,0 +103,0 @@ break; |
@@ -5,3 +5,3 @@ { | ||
"author": "Stéphan Kochen <stephan@kochen.nl>", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"homepage": "https://github.com/Two-Screen/bbnano", | ||
@@ -8,0 +8,0 @@ "repository": { |
8810
219