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

uniqorm

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniqorm - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

12

lib/DataField.js

@@ -103,6 +103,16 @@ /* UNIQORM

set defaultValue(value) {
this._defaultValue = value == null ? null : value;
this._defaultValue = this.parseValue(value);
}
// noinspection JSMethodCanBeStatic
/**
*
* @param {*} value
* @return {*}
*/
parseValue(value) {
return value == null ? null : value;
}
/**
* Registers a serializer class for given dialect

@@ -109,0 +119,0 @@ *

19

lib/fields/BOOLEAN.js

@@ -22,2 +22,3 @@ /* UNIQORM

// noinspection JSMethodCanBeStatic
/**

@@ -32,2 +33,3 @@ *

// noinspection JSMethodCanBeStatic
/**

@@ -43,17 +45,10 @@ *

/**
* @type {Boolean}
* @override
*
* @param {*} value
* @return {Boolean|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
return value == null ? null : !!value;
}
/**
* @param {Date} value
* @override
*/
set defaultValue(value) {
super.defaultValue = value == null ? null : !!value;
}
}

@@ -60,0 +55,0 @@

@@ -32,18 +32,13 @@ /* UNIQORM

/**
* @type {Date}
* @override
*
* @param {*} value
* @return {Date|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
const d = super.parseValue(value);
if (d)
d.setHours(0, 0, 0, 0);
return d;
}
/**
* @param {Date} value
* @override
*/
set defaultValue(value) {
super.defaultValue = value;
if (this.defaultValue instanceof Date)
this.defaultValue.setHours(0, 0, 0, 0);
}
}

@@ -50,0 +45,0 @@

@@ -22,2 +22,3 @@ /* UNIQORM

// noinspection JSMethodCanBeStatic
/**

@@ -32,2 +33,3 @@ *

// noinspection JSMethodCanBeStatic
/**

@@ -43,17 +45,13 @@ *

/**
* @type {Number}
* @override
*
* @param {*} value
* @return {Number|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
if (value == null)
return null;
value = parseFloat(value);
return value || value === 0 ? value : null;
}
/**
* @param {Number} value
* @override
*/
set defaultValue(value) {
super.defaultValue = parseFloat(value) || null;
}
}

@@ -60,0 +58,0 @@

@@ -43,17 +43,13 @@ /* UNIQORM

/**
* @type {Number}
* @override
*
* @param {*} value
* @return {Int|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
if (value == null)
return null;
value = parseInt(value, 10);
return value || value === 0 ? value : null;
}
/**
* @param {Number} value
* @override
*/
set defaultValue(value) {
super.defaultValue = parseInt(value, 10) || null;
}
}

@@ -60,0 +56,0 @@

@@ -43,17 +43,10 @@ /* UNIQORM

/**
* @type {String}
* @override
*
* @param {*} value
* @return {String|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
return value == null ? null : String(value);
}
/**
* @param {String} value
* @override
*/
set defaultValue(value) {
super.defaultValue = value == null ? null : String(value);
}
}

@@ -60,0 +53,0 @@

@@ -32,18 +32,13 @@ /* UNIQORM

/**
* @type {Date}
* @override
*
* @param {*} value
* @return {Date|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
const d = super.parseValue(value);
if (d)
d.setFullYear(0, 0, 0);
return d;
}
/**
* @param {Date} value
* @override
*/
set defaultValue(value) {
super.defaultValue = value;
if (this.defaultValue instanceof Date)
this.defaultValue.setFullYear(0, 0, 0);
}
}

@@ -50,0 +45,0 @@

@@ -14,3 +14,6 @@ /* UNIQORM

const DataField = require('../DataField');
const {ArgumentError} = require('errorex');
const DATE_PATTERN = /^(19[0-9]{2}|2[0-9]{3})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)(?:[ T]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(?:\.(\d{1,6}))?)?$/;
/**

@@ -44,18 +47,31 @@ *

/**
* @type {Date}
* @override
*
* @param {*} value
* @return {Date|Null}
*/
get defaultValue() {
return super.defaultValue;
parseValue(value) {
if (value == null)
return null;
if (value instanceof Date)
return value;
if (isNumeric(value))
return new Date(value);
const m = String(value).match(DATE_PATTERN);
if (!m)
throw new ArgumentError('"%s" is not a valid date format', String(value));
return new Date(
parseInt(m[1], 10),
parseInt(m[2], 10) - 1,
parseInt(m[3], 10),
parseInt(m[4], 10) || 0,
parseInt(m[5], 10) || 0,
parseInt(m[6], 10) || 0,
parseInt(m[7], 10) || 0
);
}
/**
* @param {Date} value
* @override
*/
set defaultValue(value) {
super.defaultValue = value == null ? value :
(value instanceof Date ? value : new Date(value));
}
}
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}

@@ -62,0 +78,0 @@

@@ -504,4 +504,4 @@ /* UNIQORM

/* istanbul ignore else */
if (field && (!(field.primaryKey && removePrimaryKey)))
values[field.fieldName] = attributes[name];
if (field && field.dataType && (!(field.primaryKey && removePrimaryKey)))
values[field.fieldName] = field.parseValue(attributes[name]);
});

@@ -508,0 +508,0 @@ return values;

{
"name": "uniqorm",
"description": "Multi dialect and multi schema ORM framework for enterprise level NodeJS applications",
"version": "2.2.3",
"version": "2.3.0",
"author": "Panates Ltd.",

@@ -6,0 +6,0 @@ "contributors": [

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