New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fxjs/orm

Package Overview
Dependencies
Maintainers
2
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fxjs/orm - npm Package Compare versions

Comparing version 1.9.2 to 1.9.3

lib/orm/entry/Drivers/DML/_utils.js

5

@types/DMLDriver.d.ts

@@ -36,3 +36,3 @@ /// <reference types="@fxjs/sql-query" />

type AggregationFuncTuple = [string, string]
interface DMLDriver extends FxOrmSqlDDLSync__Driver.Driver {
interface DMLDriver extends DefaultSqlDriver {
db: FxOrmDb.DatabaseBase

@@ -211,2 +211,5 @@ dialect: FxSqlQueryDialect.DialectType

/* Connection About Patch :end */
type DefaultSqlDriver = FxOrmSqlDDLSync__Driver.Driver<FxSqlQuery.Class_Query>
type DefaultSqlDialect = FxOrmSqlDDLSync__Dialect.Dialect<FxSqlQuery.Class_Query>
}

@@ -213,0 +216,0 @@

@@ -16,3 +16,11 @@ declare namespace FxOrmHelper {

getAssociationItemFromInstanceByAssocModel (reltype: string, inst: FxOrmInstance.Instance, assoc_model: FxOrmModel.Model): FxOrmAssociation.InstanceAssociationItem
getManyAssociationItemFromModel (extend_name: string, _model: FxOrmModel.Model): FxOrmAssociation.InstanceAssociationItem_HasMany
getOneAssociationItemFromModel (extend_name: string, _model: FxOrmModel.Model): FxOrmAssociation.InstanceAssociationItem_HasOne
getExtendsToAssociationItemFromModel (extend_name: string, _model: FxOrmModel.Model): FxOrmAssociation.InstanceAssociationItem_ExtendTos
getAssociationItemFromModel (reltype: string, extend_name: string, _model: FxOrmModel.Model): FxOrmAssociation.InstanceAssociationItem
prependHook (hooks: FxOrmNS.Hooks, hookName: keyof FxOrmNS.Hooks, preLogic: FxOrmNS.Hooks[keyof FxOrmNS.Hooks]): void
preReplaceHook (m: FxOrmModel.Model, opts: FxOrmModel.ModelOptions, hookName: keyof FxOrmNS.Hooks, cb: (this: FxOrmInstance.Instance, inst: FxOrmInstance.Instance) => void): void
}
}

2

@types/instance.d.ts

@@ -102,3 +102,3 @@ /// <reference path="DMLDriver.d.ts" />

*/
set: Function;
set: (path: string|string[], value: any) => void;
markAsDirty: (propName: string) => void;

@@ -105,0 +105,0 @@ dirtyProperties: {[key: string]: any};

@@ -73,5 +73,2 @@ /// <reference types="@fxjs/sql-query" />

association: FxOrmAssociation.InstanceAssociationItem_ExtendTos
} | {
type: FxOrmAssociation.AssociationType
association: FxOrmAssociation.InstanceAssociationItem
}

@@ -78,0 +75,0 @@ }

v1.9.2 / 2019-03-16
v1.9.3 / 2019-03-26
==================
* add helpers; fix lack of patch to instance in afterLoad hook.
* code clean and add some TODO.
* abstract common code in Drivers' find/count implements.
* upgrade @fxjs/sql-ddl-sync to version with typo not bound with @fxjs/sql-query
* robust for test cases.
* add pointless helpers; normalize code.
v1.9.2 / 2019-03-16
===================
* Release v1.9.2
* support `join_where` option in `ModelAssociationMethod__Options`.

@@ -6,0 +17,0 @@

@@ -351,2 +351,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

value: function () {
// TODO: shold allow passing `extra` as 2nd argument
var items = _flatten(arguments);

@@ -353,0 +354,0 @@ var cb = util.last(items) instanceof Function ? items.pop() : noOperation;

Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
const sql_query_1 = require("@fxjs/sql-query");
const mysql = require("../DB/mysql");
const shared = require("./_shared");
const DDL = require("../DDL/SQL");
const sql_query_1 = require("@fxjs/sql-query");
const utils = require("./_utils");
exports.Driver = function (config, connection, opts) {

@@ -106,27 +107,5 @@ this.dialect = 'mysql';

}
if (opts.order) {
for (let i = 0; i < opts.order.length; i++) {
q.order(opts.order[i][0], opts.order[i][1]);
}
}
if (opts.merge) {
q.from
.apply(q, [opts.merge.from.table, opts.merge.from.field, opts.merge.to.table, opts.merge.to.field].filter(x => x))
.select(opts.merge.select);
if (opts.merge.where && Object.keys(opts.merge.where[1]).length) {
q = q.where(opts.merge.where[0], opts.merge.where[1], opts.merge.table || null, conditions);
}
else {
q = q.where(opts.merge.table || null, conditions);
}
}
else {
q = q.where(conditions);
}
if (opts.exists) {
for (let k in opts.exists) {
const exist_item = opts.exists[k];
q.whereExists(exist_item.table, table, exist_item.link, exist_item.conditions);
}
}
utils.buildOrderToQuery.apply(this, [q, opts.order]);
q = utils.buildMergeToQuery.apply(this, [q, opts.merge, conditions]);
utils.buildExistsToQuery.apply(this, [q, table, opts.exists]);
this.execSimpleQuery(q.build(), cb);

@@ -138,20 +117,4 @@ };

.count(null, 'c');
if (opts.merge) {
q.from(opts.merge.from.table, opts.merge.from.field, opts.merge.to.field);
if (opts.merge.where && Object.keys(opts.merge.where[1]).length) {
q = q.where(opts.merge.where[0], opts.merge.where[1], conditions);
}
else {
q = q.where(conditions);
}
}
else {
q = q.where(conditions);
}
if (opts.exists) {
for (let k in opts.exists) {
const exist_item = opts.exists[k];
q.whereExists(exist_item.table, table, exist_item.link, exist_item.conditions);
}
}
q = utils.buildMergeToQuery.apply(this, [q, opts.merge, conditions]);
utils.buildExistsToQuery.apply(this, [q, table, opts.exists]);
q = q.build();

@@ -256,3 +219,2 @@ this.execSimpleQuery(q, cb);

return function () { return 'POINT(' + value.x + ', ' + value.y + ')'; };
break;
default:

@@ -259,0 +221,0 @@ customType = this.customTypes[property.type];

/// <reference lib="es2015" />
Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
var pg = require("pg");
var Query = require("@fxjs/sql-query").Query;
var shared = require("./_shared");
var DDL = require("../DDL/SQL");
const pg = require("pg");
const shared = require("./_shared");
const DDL = require("../DDL/SQL");
const sql_query_1 = require("@fxjs/sql-query");
const utils = require("./_utils");
var switchableFunctions = {

@@ -78,3 +79,3 @@ pool: {

}
this.query = new Query({ dialect: this.dialect, timezone: this.config.timezone });
this.query = new sql_query_1.Query({ dialect: this.dialect, timezone: this.config.timezone });
this.customTypes = {};

@@ -141,22 +142,5 @@ if (connection) {

}
if (opts.merge) {
q.from
.apply(q, [opts.merge.from.table, opts.merge.from.field, opts.merge.to.table, opts.merge.to.field].filter(x => x))
.select(opts.merge.select);
if (opts.merge.where && Object.keys(opts.merge.where[1]).length) {
q = q.where(opts.merge.where[0], opts.merge.where[1], opts.merge.table || null, conditions);
}
else {
q = q.where(opts.merge.table || null, conditions);
}
}
else {
q = q.where(conditions);
}
if (opts.exists) {
for (let k in opts.exists) {
const exist_item = opts.exists[k];
q.whereExists(exist_item.table, table, exist_item.link, exist_item.conditions);
}
}
utils.buildOrderToQuery.apply(this, [q, opts.order]);
q = utils.buildMergeToQuery.apply(this, [q, opts.merge, conditions]);
utils.buildExistsToQuery.apply(this, [q, table, opts.exists]);
q = q.build();

@@ -167,20 +151,4 @@ this.execSimpleQuery(q, cb);

var q = this.query.select().from(table).count(null, 'c');
if (opts.merge) {
q.from(opts.merge.from.table, opts.merge.from.field, opts.merge.to.field);
if (opts.merge.where && Object.keys(opts.merge.where[1]).length) {
q = q.where(opts.merge.where[0], opts.merge.where[1], conditions);
}
else {
q = q.where(conditions);
}
}
else {
q = q.where(conditions);
}
if (opts.exists) {
for (let k in opts.exists) {
const exist_item = opts.exists[k];
q.whereExists(exist_item.table, table, exist_item.link, exist_item.conditions);
}
}
q = utils.buildMergeToQuery.apply(this, [q, opts.merge, conditions]);
utils.buildExistsToQuery.apply(this, [q, table, opts.exists]);
q = q.build();

@@ -303,6 +271,3 @@ this.execSimpleQuery(q, cb);

case "point":
return function () {
return "POINT(" + value.x + ', ' + value.y + ")";
};
break;
return function () { return 'POINT(' + value.x + ', ' + value.y + ')'; };
default:

@@ -309,0 +274,0 @@ customType = this.customTypes[property.type];

Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
var sqlite3 = require("../DB/sqlite3");
var Query = require("@fxjs/sql-query").Query;
var shared = require("./_shared");
var DDL = require("../DDL/SQL");
const sqlite3 = require("../DB/sqlite3");
const shared = require("./_shared");
const DDL = require("../DDL/SQL");
const sql_query_1 = require("@fxjs/sql-query");
const utils = require("./_utils");
exports.Driver = function (config, connection, opts) {

@@ -14,3 +15,3 @@ this.dialect = 'sqlite';

}
this.query = new Query({ dialect: this.dialect, timezone: this.config.timezone });
this.query = new sql_query_1.Query({ dialect: this.dialect, timezone: this.config.timezone });
this.customTypes = {};

@@ -79,27 +80,5 @@ if (connection) {

}
if (opts.order) {
for (let i = 0; i < opts.order.length; i++) {
q.order(opts.order[i][0], opts.order[i][1]);
}
}
if (opts.merge) {
q.from
.apply(q, [opts.merge.from.table, opts.merge.from.field, opts.merge.to.table, opts.merge.to.field].filter(x => x))
.select(opts.merge.select);
if (opts.merge.where && Object.keys(opts.merge.where[1]).length) {
q = q.where(opts.merge.where[0], opts.merge.where[1], opts.merge.table || null, conditions);
}
else {
q = q.where(opts.merge.table || null, conditions);
}
}
else {
q = q.where(conditions);
}
if (opts.exists) {
for (let k in opts.exists) {
const exist_item = opts.exists[k];
q.whereExists(exist_item.table, table, exist_item.link, exist_item.conditions);
}
}
utils.buildOrderToQuery.apply(this, [q, opts.order]);
q = utils.buildMergeToQuery.apply(this, [q, opts.merge, conditions]);
utils.buildExistsToQuery.apply(this, [q, table, opts.exists]);
const qstr = q.build();

@@ -115,20 +94,4 @@ if (this.opts.debug) {

.count(null, 'c');
if (opts.merge) {
q.from(opts.merge.from.table, opts.merge.from.field, opts.merge.to.field);
if (opts.merge.where && Object.keys(opts.merge.where[1]).length) {
q = q.where(opts.merge.where[0], opts.merge.where[1], conditions);
}
else {
q = q.where(conditions);
}
}
else {
q = q.where(conditions);
}
if (opts.exists) {
for (let k in opts.exists) {
const exist_item = opts.exists[k];
q.whereExists(exist_item.table, table, exist_item.link, exist_item.conditions);
}
}
q = utils.buildMergeToQuery.apply(this, [q, opts.merge, conditions]);
utils.buildExistsToQuery.apply(this, [q, table, opts.exists]);
const qstr = q.build();

@@ -135,0 +98,0 @@ if (this.opts.debug) {

@@ -11,3 +11,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
/* by extname :start */
/* by instance extname :start */
exports.getManyAssociationItemFromInstanceByExtname = function (instance, extend_name) {

@@ -37,4 +37,4 @@ const many_assocs = exports.get_many_associations_from_instance_by_extname(instance);

};
/* by extname :end */
/* by assoc_model :start */
/* by instance extname :end */
/* by instance x assoc_model :start */
exports.getManyAssociationItemFromInstanceByAssocModel = function (instance, assoc_model) {

@@ -64,2 +64,82 @@ const many_assocs = exports.get_many_associations_from_instance_by_extname(instance);

};
/* by assoc_model :end */
/* by instance x assoc_model :end */
/* by ext_name x _model :start */
exports.getManyAssociationItemFromModel = function (ext_name, _model) {
const rel_info = _model.associations[ext_name];
if (!rel_info || rel_info.type !== 'hasMany')
return null;
return rel_info.association;
};
exports.getOneAssociationItemFromModel = function (ext_name, _model) {
const rel_info = _model.associations[ext_name];
if (!rel_info || rel_info.type !== 'hasOne')
return null;
return rel_info.association;
};
exports.getExtendsToAssociationItemFromModel = function (ext_name, _model) {
const rel_info = _model.associations[ext_name];
if (!rel_info || rel_info.type !== 'extendsTo')
return null;
return rel_info.association;
};
exports.getAssociationItemFromModel = function (reltype, extend_name, _model) {
switch (reltype) {
default:
throw 'invalid association reltype!';
case 'extendsTo':
return exports.getManyAssociationItemFromModel(extend_name, _model);
case 'hasOne':
return exports.getOneAssociationItemFromModel(extend_name, _model);
case 'hasMany':
return exports.getExtendsToAssociationItemFromModel(extend_name, _model);
}
};
/* by ext_name x assoc_model :end */
/* hooks :start */
exports.prependHook = function (hooks, hookName, preLogic) {
if (typeof hooks[hookName] === 'function') {
var oldHook = hooks[hookName];
const callOldHook = function (next) {
if (typeof oldHook === 'function') {
if (oldHook.length > 0)
return oldHook.call(this, next);
oldHook.call(this);
}
if (typeof next === 'function')
next();
};
hooks[hookName] = function (next) {
if (preLogic.length > 0) {
var self = this;
return preLogic.call(this, function () {
callOldHook.call(self, next);
});
}
preLogic.call(this);
callOldHook.call(this, next);
};
}
else {
hooks[hookName] = preLogic;
}
};
exports.preReplaceHook = function (m, opts, hookName, cb) {
var _oldHook;
if (opts !== undefined && opts.hooks)
_oldHook = opts.hooks[hookName];
m[hookName](function (next) {
cb.call(this, this);
if (_oldHook) {
if (_oldHook.length > 0) {
if (typeof next === 'boolean')
return _oldHook(next);
else
return _oldHook(next);
}
_oldHook();
}
if (typeof next === 'function')
next();
});
};
/* hooks: start */
Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
const Utilities = require("../Utilities");
const Helpers_1 = require("../Helpers");
// patch async function to sync function

@@ -8,2 +9,6 @@ function patchSync(o, funcs) {

const old_func = o[func];
/**
* we should re init the sync method in hook `afterAutoFetch`,
* so never check if new_func existed.
*/
if (old_func) {

@@ -157,19 +162,10 @@ Object.defineProperty(o, func + 'Sync', {

function patchModel(m, opts) {
var _afterAutoFetch;
if (opts !== undefined && opts.hooks)
_afterAutoFetch = opts.hooks.afterAutoFetch;
/**
* use `afterAutoFetch` rather than `afterLoad`,
* because patch in `afterLoad` only process instance's basic(exclude lazyload) fields' accessors,
* as patch in `afterAutoFetch` would process instance's basic/lazyload/associated fields' accessors
*/
m.afterAutoFetch(function (next) {
patchObject(this);
if (_afterAutoFetch) {
if (_afterAutoFetch.length > 0)
return _afterAutoFetch(next);
_afterAutoFetch();
}
next();
opts = opts || {};
opts.hooks = opts.hooks || {};
Helpers_1.preReplaceHook(m, opts, 'afterLoad', function (instance) {
patchObject(instance);
});
Helpers_1.preReplaceHook(m, opts, 'afterAutoFetch', function (instance) {
patchObject(instance);
});
patchResult(m);

@@ -176,0 +172,0 @@ patchSync(m, [

@@ -231,2 +231,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

type: p.type || "integer",
// TODO: make 32 when p.type === 'text'
size: p.size || 4,

@@ -233,0 +234,0 @@ unsigned: p.unsigned || true,

{
"name": "@fxjs/orm",
"version": "1.9.2",
"version": "1.9.3",
"description": "Object Relational Mapping for fibjs",

@@ -45,3 +45,3 @@ "main": "lib",

"@fibjs/enforce": "0.0.8",
"@fxjs/sql-ddl-sync": "^0.3.6",
"@fxjs/sql-ddl-sync": "^0.3.8",
"@fxjs/sql-query": "^0.2.5",

@@ -48,0 +48,0 @@ "lodash.clonedeep": "^4.5.0",

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