Comparing version 0.1.0 to 0.1.1
@@ -12,2 +12,4 @@ 'use strict'; | ||
var _redinkErrors = require('redink-errors'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -35,2 +37,5 @@ | ||
return db.instance.connect(); | ||
}, | ||
instance: function instance() { | ||
throw new _redinkErrors.RedinkError('Error in db singleton: Redink not initialized.'); | ||
} | ||
@@ -37,0 +42,0 @@ }; |
@@ -219,7 +219,3 @@ 'use strict'; | ||
var didSucceed = function didSucceed(archived) { | ||
var result = archived ? { deleted: true, id: id } : { deleted: false }; | ||
return result; | ||
}; | ||
var table = _rethinkdb2.default.table(type); | ||
var query = new Promise(function (resolve) { | ||
@@ -229,5 +225,10 @@ return resolve((0, _cascadeArchive2.default)(id, type, conn, schemas)); | ||
var fieldsToMerge = (0, _getFieldsToMerge2.default)(schemas, type); | ||
var fetch = function fetch() { | ||
return table.get(id).merge(fieldsToMerge).run(conn); | ||
}; | ||
return query.then(function (reql) { | ||
return new Promise(function (resolve, reject) { | ||
_rethinkdb2.default.do(reql).run(conn).then(didSucceed).then(resolve).catch( /* istanbul ignore next */function (err) { | ||
_rethinkdb2.default.do(reql).run(conn).then(fetch).then(resolve).catch( /* istanbul ignore next */function (err) { | ||
return reject(new _redinkErrors.RedinkDatabaseError('Error archiving record of type \'' + type + '\': ' + err.message)); | ||
@@ -234,0 +235,0 @@ }); |
{ | ||
"name": "redink", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "RethinkDB ORM", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
63505
1714
3