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.16.15 to 2.17.0

21

lib/Finder.js

@@ -46,3 +46,3 @@ /* UNIQORM

* @param {boolean} [options.autoCommit]
* @param {boolean} [options.silent]
* @param {boolean} [options.ignoreUnknownFields]
* @param {Function} [options.trace]

@@ -61,3 +61,3 @@ * @param {Object} options.context

this.autoCommit = options.autoCommit;
this.silent = options.silent;
this.ignoreUnknownFields = options.ignoreUnknownFields;
this.context = options.context;

@@ -248,3 +248,3 @@ this.trace = options.trace;

_processProperties() {
const {silent} = this;
const {ignoreUnknownFields} = this;

@@ -265,3 +265,4 @@ const processField = (finder, model, v, attrKey, tableAlias, targetNode) => {

v.fieldName = v.fieldName || /* istanbul ignore next */ attrKey;
const field = model.getField(v.fieldName, silent);
const field = ignoreUnknownFields ? model.findField(v.fieldName) :
model.getField(v.fieldName);
if (!field) return;

@@ -299,7 +300,4 @@

// Validate
if (v.subField) {
/* istanbul ignore next */
if (silent) return;
if (v.subField)
throw new ArgumentError('`%s` is a One2Many associated field and sub values can not be used to return as single value', v.fieldName);
}

@@ -320,3 +318,3 @@ const detailKey = field.foreignKey;

autoCommit: finder.autoCommit,
silent,
ignoreUnknownFields,
where,

@@ -356,7 +354,4 @@ sort: attrInfo.sort,

if (v.subField) {
if (fld.fieldName) {
/* istanbul ignore next */
if (silent) return;
if (fld.fieldName)
throw new ArgumentError('`%s` is a single value associated field and has no sub value `%s`', v.fieldName, v.subField);
}
const f = field.foreignModel.getField(v.subField);

@@ -363,0 +358,0 @@ targetNode.column = fnd._addColumn(tableAlias, f);

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

function normalizeFindOptions(options, silent) {
function normalizeFindOptions(options, ignoreUnknownFields) {
const result = merge({}, options);
result.properties = normalizeProperties(options.properties, silent);
result.properties =
normalizeProperties(options.properties, ignoreUnknownFields);
result.where = !options.where || Array.isArray(options.where) ?

@@ -22,6 +23,7 @@ options.where : [options.where];

options.sort : [options.sort];
result.ignoreUnknownFields = ignoreUnknownFields;
return result;
}
function normalizeProperties(properties, silent) {
function normalizeProperties(properties, ignoreUnknownFields) {

@@ -41,3 +43,3 @@ if (!properties)

value.fieldName = value.fieldName || key;
target[key] = normalizeFindOptions(value, silent);
target[key] = normalizeFindOptions(value, ignoreUnknownFields);
}

@@ -54,6 +56,4 @@ i++;

const m = v.match(COLUMN_PATTERN);
if (!m) {
if (silent) continue;
if (!m)
throw new ArgumentError('"%s" is not a valid column name', v);
}
addProperty(target, (m[3] || m[2] || m[1]),

@@ -68,4 +68,3 @@ m[1] + (m[2] ? '.' + m[2] : ''));

/* istanbul ignore next */
if (!silent)
throw new ArgumentError('"%s" is not a valid column name', v);
throw new ArgumentError('"%s" is not a valid column name', v);
}

@@ -72,0 +71,0 @@

@@ -220,11 +220,18 @@ /* UNIQORM

* @param {string} name
* @param {boolean} [silent]
* @return {DataField}
*/
getField(name, silent) {
findField(name) {
return this.fields[name];
}
/**
*
* @param {string} name
* @return {DataField}
*/
getField(name) {
const field = this.fields[name];
if (field)
return field;
if (silent) return null;
throw new ArgumentError('Model "%s" has no field "%s"', this.name, name);
if (!field)
throw new ArgumentError('Model "%s" has no field "%s"', this.name, name);
return field;
}

@@ -241,3 +248,3 @@

* @param {Boolean} [options.autoCommit]
* @param {Boolean} [options.silent]
* @param {Boolean} [options.ignoreUnknownFields]
* @param {Function} [options.trace]

@@ -276,3 +283,3 @@ * @param {*} [options.context]

* @param {Boolean} [options.autoCommit]
* @param {Boolean} [options.silent]
* @param {Boolean} [options.ignoreUnknownFields]
* @param {Function} [options.trace]

@@ -292,8 +299,8 @@ * @param {*} [options.context]

const silent = options.silent != null ?
options.silent : this.orm.options.silent;
const opts = normalizeFindOptions(options, silent);
const ignoreUnknownFields = options.ignoreUnknownFields != null ?
options.ignoreUnknownFields : this.orm.options.ignoreUnknownFields;
const opts = normalizeFindOptions(options, ignoreUnknownFields);
opts.model = this;
opts.connection = options.connection || this.orm.pool;
opts.silent = silent;
opts.ignoreUnknownFields = ignoreUnknownFields;
opts.trace = options.trace;

@@ -314,3 +321,3 @@ opts.sort = opts.sort || this._defaultSort;

* @param {Boolean} [options.autoCommit]
* @param {Boolean} [options.silent]
* @param {Boolean} [options.ignoreUnknownFields]
* @param {*} [options.context]

@@ -326,8 +333,7 @@ * @param {string|Array<string>} [options.returning]

const silent = options.silent != null ?
options.silent : this.orm.options.silent;
this.validateValuesForCreate(values, {silent, context: options.context});
this.validateValuesForCreate(values, options.context, {
ignoreUnknownFields: options.ignoreUnknownFields
});
const dataValues = this._normalizeValues(values);
const returning = this._prepareReturningOptions(options.returning, silent);
const returning = this._prepareReturningOptions(options.returning);

@@ -349,3 +355,2 @@ const dbobj = (options.connection || this.orm.pool);

const rows = resp.rows;
returning.silent = silent;
returning.context = options.context;

@@ -374,3 +379,3 @@ return this._prepareReturningResponse(dbobj, rows, returning)

* @param {Object} [options.connection]
* @param {Boolean} [options.silent]
* @param {Boolean} [options.ignoreUnknownFields]
* @param {*} [options.context]

@@ -400,3 +405,2 @@ * @param {string|Array<string>} [options.returning]

* @param {Object} [options.connection]
* @param {Boolean} [options.silent]
* @param {*} [options.context]

@@ -409,7 +413,7 @@ * @param {string|Array<string>} [options.returning]

const silent = options.silent != null ?
options.silent : this.orm.options.silent;
this.validateValuesForUpdate(values, {silent});
this.validateValuesForUpdate(values, options.context, {
ignoreUnknownFields: options.ignoreUnknownFields
});
const dataValues = this._normalizeValues(values);
const returning = this._prepareReturningOptions(options.returning, silent);
const returning = this._prepareReturningOptions(options.returning);

@@ -435,3 +439,2 @@ let where = this._mapConditions(options.where);

const rows = resp.rows;
returning.silent = silent;
returning.context = options.context;

@@ -458,3 +461,2 @@ return this._prepareReturningResponse(dbobj, rows, returning)

* @param {Object} [options.connection]
* @param {Boolean} [options.silent]
* @return {Promise<{executeTime:number, queriesExecuted:number, rowsAffected:number}>}

@@ -475,3 +477,2 @@ */

* @param {Object} [options.connection]
* @param {Boolean} [options.silent]
* @return {Promise<{executeTime:number, queriesExecuted:number, rowsAffected:number}>}

@@ -569,3 +570,3 @@ */

_prepareReturningOptions(value, silent) {
_prepareReturningOptions(value) {
if (!value)

@@ -575,3 +576,3 @@ return;

(typeof value === 'object' ? value : [value]);
properties = normalizeProperties(properties, silent);
properties = normalizeProperties(properties);
/* Be sure key fields exists in properties */

@@ -657,3 +658,2 @@ /* istanbul ignore else */

connection: dbobj,
silent: options.silent,
properties: options.properties,

@@ -692,10 +692,9 @@ where: [],

* @param {Object} values
* @param {*} [context]
* @param {Object} [options]
* @param {boolean} [options.silent=false]
* @param {boolean} [options.normalize=false]
* @param {*} [options.context]
* @param {boolean} [options.ignoreUnknownFields=false]
* @return {Object}
*/
validateValuesForCreate(values, options = {}) {
return this._validateValues(values, {
validateValuesForCreate(values, context, options = {}) {
return this._validateValues(values, context, {
...options,

@@ -709,10 +708,9 @@ forCreate: true

* @param {Object} values
* @param {*} [context]
* @param {Object} [options]
* @param {boolean} [options.silent=false]
* @param {boolean} [options.normalize=false]
* @param {*} [options.context]
* @param {boolean} [options.ignoreUnknownFields=false]
* @return {Object}
*/
validateValuesForUpdate(values, options = {}) {
return this._validateValues(values, {
validateValuesForUpdate(values, context, options = {}) {
return this._validateValues(values, context, {
...options,

@@ -726,9 +724,9 @@ forCreate: false

* @param {Object} values
* @param {*} [context]
* @param {Object} [options]
* @param {boolean} [options.silent=false]
* @param {boolean} [options.ignoreUnknownFields=false]
* @param {boolean} [options.forCreate=false]
* * @param {*} [options.context]
* @private
*/
_validateValues(values, options = {}) {
_validateValues(values, context, options = {}) {
if (typeof values !== 'object' || Array.isArray(values))

@@ -738,3 +736,3 @@ throw new ArgumentError('You must provide values');

/* istanbul ignore else */
if (!options.silent) {
if (!options.ignoreUnknownFields) {
for (const name of Object.keys(values)) {

@@ -772,3 +770,3 @@ this.getField(name);

}
field.validateValue(v, values, options.context);
field.validateValue(v, values, context);
}

@@ -775,0 +773,0 @@ }

@@ -30,3 +30,3 @@ /* UNIQORM

* @param {Object} [options]
* @param {Boolean} [options.silent]
* @param {Boolean} [options.ignoreUnknownFields]
* @param {Boolean} [options.defaultPrimaryKey='id']

@@ -36,3 +36,3 @@ * @constructor

*/
constructor(sqbPool, options) {
constructor(sqbPool, options = {}) {
super();

@@ -44,3 +44,3 @@ if (sqbPool && typeof sqbPool.select !== 'function')

this._schemas = {};
this.options = options || {};
this.options = options;
this.options.defaultPrimaryKey = this.options.defaultPrimaryKey || 'id';

@@ -47,0 +47,0 @@ }

{
"name": "uniqorm",
"description": "Multi dialect and multi schema ORM framework for enterprise level NodeJS applications",
"version": "2.16.15",
"version": "2.17.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