Comparing version 1.13.6 to 1.13.7
@@ -789,3 +789,3 @@ var eventEmitter = require('events').EventEmitter; | ||
else { | ||
try{ // Validate the doc, replace it, and tag it as saved | ||
util.tryCatch(function() { // Validate the doc, replace it, and tag it as saved | ||
Document.prototype.__validate(result.new_val, model._schema, '', model._options, self) | ||
@@ -797,6 +797,3 @@ self._merge(result.new_val) | ||
saveMany(); | ||
} | ||
catch(err) { | ||
reject(err); | ||
} | ||
}, reject); | ||
} | ||
@@ -806,3 +803,3 @@ } | ||
var saveSelfHelper = function() { | ||
try{ | ||
util.tryCatch(function() { | ||
// Validate the document before saving it | ||
@@ -812,6 +809,3 @@ Document.prototype.__validate(copy, model._schema, '', model._options, self) | ||
r.table(constructor.getTableName()).insert(copy, {returnVals: true}).run().then(savedDocCb).error(reject) | ||
} | ||
catch(err) { | ||
reject(err); | ||
} | ||
}, reject); | ||
} | ||
@@ -836,3 +830,3 @@ | ||
else { | ||
try{ | ||
util.tryCatch(function() { | ||
Document.prototype.__validate(result.new_val, model._schema, '', model._options, self) | ||
@@ -844,6 +838,3 @@ self._merge(result.new_val) | ||
saveMany(); | ||
} | ||
catch(err) { | ||
reject(err); | ||
} | ||
}, reject); | ||
} | ||
@@ -850,0 +841,0 @@ }).error(reject) |
@@ -834,5 +834,12 @@ var util = require(__dirname+'/util.js'); | ||
var insert = function() { | ||
util.tryCatch(function() { | ||
for(var i=0; i<docs.length; i++) { | ||
docs[i] = new self(docs[i]); | ||
docs[i].validate(); | ||
} | ||
}, reject); | ||
r.table(self.getTableName()).insert(docs).run().then(function(results) { | ||
if ((results.errors === 0) && (results.inserted === docs.length)) { | ||
try { | ||
util.tryCatch(function() { | ||
var index = 0; | ||
@@ -848,9 +855,6 @@ // Set the primary keys | ||
for(i=0; i<docs.length; i++) { | ||
docs[i] = new self(docs[i]); | ||
docs[i].setSaved() | ||
} | ||
resolve(docs); | ||
} | ||
catch(err) { | ||
reject(err); | ||
} | ||
}, reject) | ||
} | ||
@@ -893,3 +897,3 @@ else { | ||
data.toArray().then(function(result) { | ||
try{ | ||
util.tryCatch(function() { | ||
for(var i=0; i<result.length; i++) { | ||
@@ -902,4 +906,3 @@ self.emit('retrieved', result[i]); | ||
resolve(result); | ||
} | ||
catch(error) { | ||
}, function(error) { | ||
var newError = new Error(); | ||
@@ -909,3 +912,3 @@ newError.message = "The results could not be converted to instances of `"+self.getTableName()+"`\nDetailed error: "+error.message | ||
return reject(newError); | ||
} | ||
}); | ||
}).error(reject) | ||
@@ -916,3 +919,3 @@ } | ||
if (util.isPlainObject(data) && (data.$reql_type$ === "GROUPED_DATA")) { | ||
try{ | ||
util.tryCatch(function() { | ||
var result = []; | ||
@@ -949,6 +952,3 @@ var reduction, newDoc; | ||
resolve(result) | ||
} | ||
catch(err) { | ||
reject(err) | ||
} | ||
}, reject); | ||
} | ||
@@ -960,3 +960,3 @@ else { | ||
else { | ||
try{ | ||
util.tryCatch(function() { | ||
self.emit('retrieved', data); | ||
@@ -967,6 +967,3 @@ data = new self(data); | ||
resolve(data) | ||
} | ||
catch(error) { | ||
reject(error); | ||
} | ||
}, reject); | ||
} | ||
@@ -973,0 +970,0 @@ } |
@@ -124,3 +124,14 @@ var util = require('util'); | ||
function tryCatch(toTry, handleError) { | ||
try{ | ||
toTry() | ||
} | ||
catch(err) { | ||
handleError(err) | ||
} | ||
} | ||
util.tryCatch = tryCatch; | ||
module.exports = util; | ||
{ | ||
"name": "thinky", | ||
"version": "1.13.6", | ||
"version": "1.13.7", | ||
"description": "RethinkDB ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/thinky.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121408
2685