Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

thinky

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thinky - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

47

lib/errors.js

@@ -0,1 +1,8 @@

var DOCUMENT_NOT_FOUND_REGEX = new RegExp('^The query did not find a document and returned null.*');
module.exports.DOCUMENT_NOT_FOUND_REGEX = DOCUMENT_NOT_FOUND_REGEX;
var DUPLICATE_PRIMARY_KEY_REGEX = new RegExp('^Duplicate primary key.*');
module.exports.DUPLICATE_PRIMARY_KEY_REGEX = DUPLICATE_PRIMARY_KEY_REGEX;
/**

@@ -9,3 +16,4 @@ * DocumentNotFound error which is returned when `get` returns `null`.

};
DocumentNotFound.prototype = new Error();
DocumentNotFound.prototype = Object.create(Error.prototype);
DocumentNotFound.prototype.constructor = DocumentNotFound;
DocumentNotFound.prototype.name = "Document not found";

@@ -25,3 +33,4 @@ module.exports.DocumentNotFound = DocumentNotFound;

};
InvalidWrite.prototype = new Error();
InvalidWrite.prototype = Object.create(Error.prototype);
InvalidWrite.prototype.constructor = InvalidWrite;
InvalidWrite.prototype.name = "Invalid write";

@@ -39,4 +48,36 @@ module.exports.InvalidWrite = InvalidWrite;

};
ValidationError.prototype = new Error();
ValidationError.prototype = Object.create(Error.prototype);
ValidationError.prototype.constructor = ValidationError;
ValidationError.prototype.name = "Document failed validation";
module.exports.ValidationError = ValidationError;
/**
* DuplicatePrimaryKey error which is returned when the primary key unique constraint of a document fails.
* "Extends" Error
*/
function DuplicatePrimaryKey(message) {
Error.captureStackTrace(this, DuplicatePrimaryKey);
this.message = message;
};
DuplicatePrimaryKey.prototype = new Error();
DuplicatePrimaryKey.prototype.name = "Duplicate primary key";
module.exports.DuplicatePrimaryKey = DuplicatePrimaryKey;
module.exports.create = function (errorOrMessage) {
var message = (errorOrMessage instanceof Error) ? errorOrMessage.message : errorOrMessage;
if(message.match(DOCUMENT_NOT_FOUND_REGEX)) {
return new DocumentNotFound(message);
}
if(message.match(DUPLICATE_PRIMARY_KEY_REGEX)) {
return new DuplicatePrimaryKey(message);
}
if (errorOrMessage instanceof Error) {
return errorOrMessage;
}
return new Error(errorOrMessage);
};

7

lib/query.js

@@ -200,8 +200,3 @@ var Promise = require('bluebird');

}).catch(function(err) {
var notFoundRegex = new RegExp('^' + new Errors.DocumentNotFound().message);
if (err.message.match(notFoundRegex)) {
//Reject with an instance of Errors.DocumentNotFound
err = new Errors.DocumentNotFound(err.message);
}
return Promise.reject(err);
return Promise.reject(Errors.create(err));
})

@@ -208,0 +203,0 @@ };

{
"name": "thinky",
"version": "2.2.0",
"version": "2.2.1",
"description": "RethinkDB ORM for Node.js",

@@ -5,0 +5,0 @@ "main": "lib/thinky.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc