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.12.1 to 1.13.0

lib/Drivers/DB/postgres.js

7

lib/AggregateFunctions.js

@@ -138,4 +138,7 @@ const ORMError = require("./Error");

}
const syncReponse = Utilities.exposeErrAndResultFromSyncMethod(proto.getSync, [], { thisArg: proto });
Utilities.throwErrOrCallabckErrResult(syncReponse, {
const syncReponse = Utilities.catchBlocking(proto.getSync, [], { thisArg: proto });
if (syncReponse.error instanceof ORMError && syncReponse.error.code === ORMError.codes['PARAM_MISMATCH']) {
throw syncReponse.error;
}
Utilities.takeAwayResult(syncReponse, {
callback: cb && function (err, results) {

@@ -142,0 +145,0 @@ if (err)

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

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.hasSyncAccessor]);
const syncResponse = Utilities.catchBlocking(Instance[association.hasSyncAccessor]);
syncResponse.result = !!syncResponse.result;
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -181,4 +181,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.getSyncAccessor], [opts]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.getSyncAccessor], [opts]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -217,4 +217,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.setSyncAccessor], [Extension]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.setSyncAccessor], [Extension]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -250,4 +250,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.delSyncAccessor]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.delSyncAccessor]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -254,0 +254,0 @@ return this;

@@ -235,4 +235,4 @@ /// <reference lib="es5" />

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.hasSyncAccessor], Instances);
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.hasSyncAccessor], Instances);
Utilities.takeAwayResult(syncResponse, { callback: cb });
});

@@ -348,4 +348,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.setSyncAccessor], items);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.setSyncAccessor], items);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -365,4 +365,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.delSyncAccessor], args);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.delSyncAccessor], args);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -507,4 +507,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.addSyncAccessor], args);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: !withExtraProps, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.addSyncAccessor], args);
Utilities.takeAwayResult(syncResponse, { no_throw: !withExtraProps, callback: cb });
errWaitor.err = syncResponse.error;

@@ -511,0 +511,0 @@ if (errWaitor.evt)

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

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.hasSyncAccessor], [_has_opts]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.hasSyncAccessor], [_has_opts]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -195,4 +195,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(getAccessorChainOrRunSync, [opts, !withCallback]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(getAccessorChainOrRunSync, [opts, !withCallback]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -248,4 +248,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.setSyncAccessor], [OtherInstance]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.setSyncAccessor], [OtherInstance]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -277,4 +277,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[association.delSyncAccessor]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[association.delSyncAccessor]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -281,0 +281,0 @@ return this;

const util = require("util");
const Utilities = require("./Utilities");
const ChainInstance = require("./ChainInstance");
var prepareConditions = function (opts) {
const prepareConditions = function (opts) {
return Utilities.transformPropertyNames(opts.conditions, opts.properties);
};
var prepareOrder = function (opts) {
const prepareOrder = function (opts) {
return Utilities.transformOrderPropertyNames(opts.order, opts.properties);

@@ -19,3 +19,3 @@ };

const conditions = Utilities.transformPropertyNames(opts.conditions, opts.properties);
Utilities.filterWhereConditionsInput(conditions, Model);
Utilities.filterWhereConditionsInput(conditions, { allProperties: Model.allProperties });
const order = Utilities.transformOrderPropertyNames(opts.order, opts.properties);

@@ -28,3 +28,12 @@ let foundItems;

offset: opts.offset,
exists: opts.exists
exists: opts.exists.map(existCond => {
var _a;
const maybeAssoc = (_a = Object.values(Model.associations).find(({ association }) => association.mergeTable === existCond.table)) === null || _a === void 0 ? void 0 : _a.association;
const mergeProps = (maybeAssoc === null || maybeAssoc === void 0 ? void 0 : maybeAssoc.props) || null;
if (mergeProps) {
existCond.conditions = Utilities.transformPropertyNames(existCond.conditions, mergeProps);
Utilities.filterWhereConditionsInput(existCond.conditions, { allProperties: mergeProps });
}
return existCond;
})
});

@@ -69,4 +78,4 @@ if (foundItems.length === 0) {

const chainRun = function (done) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(chainRunSync);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: done, use_tick: true });
const syncResponse = Utilities.catchBlocking(chainRunSync);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: done, use_tick: true });
};

@@ -95,3 +104,3 @@ const chain = {

omit: function () {
var omit = null;
let omit = null;
if (arguments.length && Array.isArray(arguments[0])) {

@@ -185,4 +194,4 @@ omit = arguments[0];

process.nextTick(() => {
const syncResult = Utilities.exposeErrAndResultFromSyncMethod(chain.countSync);
Utilities.throwErrOrCallabckErrResult(syncResult, { callback: cb });
const syncResult = Utilities.catchBlocking(chain.countSync);
Utilities.takeAwayResult(syncResult, { callback: cb });
});

@@ -201,4 +210,4 @@ return this;

process.nextTick(() => {
const syncResult = Utilities.exposeErrAndResultFromSyncMethod(chain.removeSync);
Utilities.throwErrOrCallabckErrResult(syncResult, { callback: cb });
const syncResult = Utilities.catchBlocking(chain.removeSync);
Utilities.takeAwayResult(syncResult, { callback: cb });
});

@@ -205,0 +214,0 @@ return this;

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

connect(cb) {
const exposedErrResults = Utilities.exposeErrAndResultFromSyncMethod(() => super.open());
Utilities.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: !!cb, callback: cb });
const exposedErrResults = Utilities.catchBlocking(() => super.open());
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
return this.connection;
}
query(sql, cb) {
const exposedErrResults = Utilities.exposeErrAndResultFromSyncMethod(() => this.execute(sql));
Utilities.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: !!cb, callback: cb });
const exposedErrResults = Utilities.catchBlocking(() => this.execute(sql));
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
return exposedErrResults.result;

@@ -22,0 +22,0 @@ }

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

connect(cb) {
const exposedErrResults = Utilities.exposeErrAndResultFromSyncMethod(() => super.open());
Utilities.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: !!cb, callback: cb });
const exposedErrResults = Utilities.catchBlocking(() => super.open());
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
return this.connection;
}
query(sql, cb) {
const exposedErrResults = Utilities.exposeErrAndResultFromSyncMethod(() => this.execute(sql));
Utilities.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: !!cb, callback: cb });
const exposedErrResults = Utilities.catchBlocking(() => this.execute(sql));
Utilities.takeAwayResult(exposedErrResults, { no_throw: !!cb, callback: cb });
return exposedErrResults.result;

@@ -29,0 +29,0 @@ }

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

for (let i = 0; i < drop_queries.length; i++) {
err = Utilities.exposeErrAndResultFromSyncMethod(this.execQuery, [drop_queries[i]], { thisArg: this }).error;
err = Utilities.catchBlocking(this.execQuery, [drop_queries[i]], { thisArg: this }).error;
if (err || --pending === 0)

@@ -45,0 +45,0 @@ break;

Object.defineProperty(exports, "__esModule", { value: true });
require("./mysql");
require("./postgres");
require("./sqlite");

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

exports.Driver.prototype.connect = function (cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
return this.db.connect();
});
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return syncResponse.result;

@@ -70,3 +70,3 @@ };

this.db = new mysql.Database(connOpts);
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
return this.connect();

@@ -79,4 +79,4 @@ });

exports.Driver.prototype.close = function (cb) {
const errResults = Utilities.exposeErrAndResultFromSyncMethod(() => this.db.close());
Utilities.throwErrOrCallabckErrResult(errResults, { no_throw: !!cb, callback: cb });
const errResults = Utilities.catchBlocking(() => this.db.close());
Utilities.takeAwayResult(errResults, { no_throw: !!cb, callback: cb });
return errResults.result;

@@ -125,3 +125,3 @@ };

.build();
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
const info = this.execSimpleQuery(q);

@@ -142,3 +142,3 @@ const ids = {};

});
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return syncResponse.result;

@@ -145,0 +145,0 @@ };

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

exports.Driver.prototype.ping = function (cb) {
Utilities.throwErrOrCallabckErrResult({ error: null }, { callback: cb, use_tick: true });
Utilities.takeAwayResult({ error: null }, { callback: cb, use_tick: true });
return this;

@@ -56,9 +56,9 @@ };

exports.Driver.prototype.connect = function (cb) {
const errResults = Utilities.exposeErrAndResultFromSyncMethod(() => this.db.connect());
Utilities.throwErrOrCallabckErrResult(errResults, { no_throw: !!cb, callback: cb });
const errResults = Utilities.catchBlocking(() => this.db.connect());
Utilities.takeAwayResult(errResults, { no_throw: !!cb, callback: cb });
return errResults.result;
};
exports.Driver.prototype.close = function (cb) {
const errResults = Utilities.exposeErrAndResultFromSyncMethod(() => this.db.close());
Utilities.throwErrOrCallabckErrResult(errResults, { no_throw: !!cb, callback: cb });
const errResults = Utilities.catchBlocking(() => this.db.close());
Utilities.takeAwayResult(errResults, { no_throw: !!cb, callback: cb });
return errResults.result;

@@ -110,3 +110,3 @@ };

}
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
const info = this.execSimpleQuery(q);

@@ -128,3 +128,3 @@ if (!keyProperties)

});
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return syncResponse.result;

@@ -154,3 +154,3 @@ };

exports.Driver.prototype.clear = function (table, cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
this.execQuery(this.query.remove()

@@ -164,3 +164,3 @@ .from(table)

});
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return syncResponse.result;

@@ -167,0 +167,0 @@ };

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

const args = Array.prototype.slice.apply(arguments);
errWaitor.err = Utilities.exposeErrAndResultFromSyncMethod(() => next.apply(null, args)).error;
errWaitor.err = Utilities.catchBlocking(() => next.apply(null, args)).error;
errWaitor.evt.set();

@@ -77,0 +77,0 @@ };

@@ -171,3 +171,3 @@ /// <reference types="@fibjs/types" />

if (shouldSaveAssocs(saveOptions)) {
const syncReponse = Utilities.exposeErrAndResultFromSyncMethod(saveAssociationsSync);
const syncReponse = Utilities.catchBlocking(saveAssociationsSync);
err = syncReponse.error;

@@ -189,3 +189,3 @@ }

}
const { error: err, result: assocSaved } = Utilities.exposeErrAndResultFromSyncMethod(saveAssociationsSync);
const { error: err, result: assocSaved } = Utilities.catchBlocking(saveAssociationsSync);
if (saved || assocSaved) {

@@ -209,3 +209,3 @@ runSyncAfterSaveActions(false, err);

Utilities.filterWhereConditionsInput(conditions, instance.model());
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => opts.driver.update(opts.table, changes, conditions));
const syncResponse = Utilities.catchBlocking(() => opts.driver.update(opts.table, changes, conditions));
if (syncResponse.error) {

@@ -226,3 +226,3 @@ saveError(syncResponse.error);

let error = null;
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
instance[syncVersionAccessor](instances);

@@ -240,3 +240,3 @@ });

}
Utilities.throwErrOrCallabckErrResult({ error: error, result: assocSaved }, { callback: cb });
Utilities.takeAwayResult({ error: error, result: assocSaved }, { callback: cb });
};

@@ -335,3 +335,3 @@ const _saveOneAssociation = function (assoc) {

Utilities.filterWhereConditionsInput(conditions, instance.model());
const syncReponse = Utilities.exposeErrAndResultFromSyncMethod(() => opts.driver.update(opts.table, changes, conditions));
const syncReponse = Utilities.catchBlocking(() => opts.driver.update(opts.table, changes, conditions));
if (!syncReponse.error)

@@ -428,3 +428,3 @@ opts.data[key] = value;

var addInstanceExtraProperty = function (key) {
if (!instance.hasOwnProperty("extra")) {
if (!instance.hasOwnProperty("extra") || instance.extra === "") {
instance.extra = {};

@@ -536,4 +536,4 @@ }

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(instance.saveSync, args);
Utilities.throwErrOrCallabckErrResult({ error: syncResponse.error, result: instance }, { no_throw: !!cb, callback: cb });
const syncResponse = Utilities.catchBlocking(instance.saveSync, args);
Utilities.takeAwayResult({ error: syncResponse.error, result: instance }, { no_throw: !!cb, callback: cb });
});

@@ -562,3 +562,3 @@ return this;

Utilities.filterWhereConditionsInput(conditions, instance.model());
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => opts.driver.remove(opts.table, conditions));
const syncResponse = Utilities.catchBlocking(() => opts.driver.remove(opts.table, conditions));
Hook.trigger(instance, opts.hooks.afterRemove, !syncResponse.error);

@@ -573,4 +573,4 @@ emitCallbackStyleEvent("remove", syncResponse.error, instance);

Utilities.addHiddenUnwritableMethodToInstance(instance, "remove", function (cb) {
const syncReponse = Utilities.exposeErrAndResultFromSyncMethod(() => instance.removeSync());
Utilities.throwErrOrCallabckErrResult(syncReponse, { callback: cb });
const syncReponse = Utilities.catchBlocking(() => instance.removeSync());
Utilities.takeAwayResult(syncReponse, { callback: cb });
return this;

@@ -577,0 +577,0 @@ });

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

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[propertyAccessors.getSyncAccessor]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[propertyAccessors.getSyncAccessor]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -54,4 +54,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[propertyAccessors.removeSyncAccessor]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[propertyAccessors.removeSyncAccessor]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -73,4 +73,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(Instance[propertyAccessors.setSyncAccessor], [content]);
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: true, callback: cb });
const syncResponse = Utilities.catchBlocking(Instance[propertyAccessors.setSyncAccessor], [content]);
Utilities.takeAwayResult(syncResponse, { no_throw: true, callback: cb });
});

@@ -77,0 +77,0 @@ return this;

@@ -185,4 +185,4 @@ /// <reference lib="es2017" />

model.drop = function (cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(model.dropSync, [], { thisArg: model });
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
const syncResponse = Utilities.catchBlocking(model.dropSync, [], { thisArg: model });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return this;

@@ -206,3 +206,3 @@ };

model.sync = function (cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResponse = Utilities.catchBlocking(() => {
if (typeof m_opts.driver.sync !== "function") {

@@ -213,3 +213,3 @@ throw new ORMError("Driver does not support Model.sync()", 'NO_SUPPORT', { model: m_opts.table });

});
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return this;

@@ -293,4 +293,4 @@ };

process.nextTick(() => {
const syncReponse = Utilities.exposeErrAndResultFromSyncMethod(model.getSync, args, { thisArg: model });
Utilities.throwErrOrCallabckErrResult(syncReponse, { no_throw: true, callback: cb });
const syncReponse = Utilities.catchBlocking(model.getSync, args, { thisArg: model });
Utilities.takeAwayResult(syncReponse, { no_throw: true, callback: cb });
});

@@ -493,4 +493,4 @@ return this;

process.nextTick(() => {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(model.countSync, [conditions, cb], { thisArg: model });
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
const syncResponse = Utilities.catchBlocking(model.countSync, [conditions, cb], { thisArg: model });
Utilities.takeAwayResult(syncResponse, { callback: cb });
});

@@ -585,4 +585,4 @@ return this;

}
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(model.existsSync, ids, { thisArg: model });
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
const syncResponse = Utilities.catchBlocking(model.existsSync, ids, { thisArg: model });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return this;

@@ -600,4 +600,4 @@ };

});
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(model.createSync, args, { thisArg: model });
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: done });
const syncResponse = Utilities.catchBlocking(model.createSync, args, { thisArg: model });
Utilities.takeAwayResult(syncResponse, { callback: done });
return syncResponse.result;

@@ -604,0 +604,0 @@ };

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

}
const syncResult = Utilities.exposeErrAndResultFromSyncMethod(() => {
const syncResult = Utilities.catchBlocking(() => {
const DMLDriver = adapters.get(proto);

@@ -110,3 +110,3 @@ const settings = exports.Settings.Container(SettingsInstance.get('*'));

}
Utilities.throwErrOrCallabckErrResult(syncResult, { no_throw: false });
Utilities.takeAwayResult(syncResult, { no_throw: false });
return orm;

@@ -125,3 +125,3 @@ }

args = args.filter((x) => x !== cb);
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(connectSync, args);
const syncResponse = Utilities.catchBlocking(connectSync, args);
let orm = null;

@@ -132,3 +132,3 @@ if (syncResponse.error)

orm = syncResponse.result;
Utilities.throwErrOrCallabckErrResult(syncResponse, {
Utilities.takeAwayResult(syncResponse, {
// no throw it, it could be processed with event handler

@@ -250,4 +250,4 @@ no_throw: true,

exports.ORM.prototype.close = function (cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(this.closeSync, [], { thisArg: this });
Utilities.throwErrOrCallabckErrResult(syncResponse, { callback: cb });
const syncResponse = Utilities.catchBlocking(this.closeSync, [], { thisArg: this });
Utilities.takeAwayResult(syncResponse, { callback: cb });
return this;

@@ -288,4 +288,4 @@ };

exports.ORM.prototype.sync = function (cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(this.syncSync, [], { thisArg: this });
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: !!cb, callback: cb });
const syncResponse = Utilities.catchBlocking(this.syncSync, [], { thisArg: this });
Utilities.takeAwayResult(syncResponse, { no_throw: !!cb, callback: cb });
return this;

@@ -302,4 +302,4 @@ };

exports.ORM.prototype.drop = function (cb) {
const syncResponse = Utilities.exposeErrAndResultFromSyncMethod(this.dropSync, [], { thisArg: this });
Utilities.throwErrOrCallabckErrResult(syncResponse, { no_throw: !!cb, callback: cb });
const syncResponse = Utilities.catchBlocking(this.dropSync, [], { thisArg: this });
Utilities.takeAwayResult(syncResponse, { no_throw: !!cb, callback: cb });
return this;

@@ -306,0 +306,0 @@ };

Object.defineProperty(exports, "__esModule", { value: true });
exports.arraify = exports.attachOnceTypedHookRefToInstance = exports.createHookHelper = exports.reusableChannelGenerator = exports.hookHandlerDecorator = exports.buildAssociationActionHooksPayload = exports.bindInstance = exports.makeIdForDriverTable = exports.generateUID4Model = exports.generateUID4ChainFind = exports.generateUID4SoloGet = exports.addHookPatchHelperForAssociation = exports.fillSyncVersionAccessorForAssociation = exports.addHiddenReadonlyPropertyToInstance = exports.addHiddenPropertyToInstance = exports.addHiddenUnwritableMethodToInstance = exports.addUnwritableProperty = exports.filterWhereConditionsInput = exports.is_model_conjunctions_key = exports.parallelQueryIfPossible = exports.getValueWaitor = exports.getErrWaitor = exports.doWhenErrIs = exports.throwErrOrCallabckErrResult = exports.exposeErrAndResultFromSyncMethod = exports.isDriverNotSupportedError = exports.queryParamCast = exports.ORM_Error = exports.tableAliasCalculatorInOneQuery = exports.tableAlias = exports.parseFallbackTableAlias = exports.combineMergeInfoToArray = exports.formatNameFor = exports.ucfirst = exports.camelCaseHasMany = exports.renameDatastoreFieldsToPropertyNames = exports.transformOrderPropertyNames = exports.transformPropertyNames = exports.getRealPath = exports.convertPropToJoinKeyProp = exports.formatAssociatedField = exports.wrapFieldObject = exports.getConditions = exports.populateModelIdKeysConditions = exports.hasValues = exports.values = exports.checkConditions = exports.addTableToStandardedOrder = exports.standardizeOrder = void 0;
exports.arraify = exports.attachOnceTypedHookRefToInstance = exports.createHookHelper = exports.reusableChannelGenerator = exports.hookHandlerDecorator = exports.buildAssociationActionHooksPayload = exports.bindInstance = exports.makeIdForDriverTable = exports.generateUID4Model = exports.generateUID4ChainFind = exports.generateUID4SoloGet = exports.addHookPatchHelperForAssociation = exports.fillSyncVersionAccessorForAssociation = exports.addHiddenReadonlyPropertyToInstance = exports.addHiddenPropertyToInstance = exports.addHiddenUnwritableMethodToInstance = exports.addUnwritableProperty = exports.filterWhereConditionsInput = exports.is_model_conjunctions_key = exports.parallelQueryIfPossible = exports.getValueWaitor = exports.getErrWaitor = exports.doWhenErrIs = exports.takeAwayResult = exports.catchBlocking = exports.isDriverNotSupportedError = exports.queryParamCast = exports.ORM_Error = exports.tableAliasCalculatorInOneQuery = exports.tableAlias = exports.parseFallbackTableAlias = exports.combineMergeInfoToArray = exports.formatNameFor = exports.ucfirst = exports.camelCaseHasMany = exports.renameDatastoreFieldsToPropertyNames = exports.transformOrderPropertyNames = exports.transformPropertyNames = exports.getRealPath = exports.convertPropToJoinKeyProp = exports.formatAssociatedField = exports.wrapFieldObject = exports.getConditions = exports.populateModelIdKeysConditions = exports.hasValues = exports.values = exports.checkConditions = exports.addTableToStandardedOrder = exports.standardizeOrder = void 0;
const util = require("util");

@@ -349,2 +349,15 @@ const uuid = require("uuid");

;
/**
* @description rename a field name in <dataIn> according to the name map in <properties>
* @example
* ```
* dataIn: { a: 1, b: 2 };
* properties: { a: { mapsTo: 'a1' }, b: { mapsTo: 'b' } };
* -->
* result: { a1: 1, b: 2 };
* ```
*
* @param dataIn
* @param properties
*/
function transformPropertyNames(dataIn, properties) {

@@ -479,3 +492,3 @@ var prop;

function isDriverNotSupportedError(err) {
if (err.code === "MODULE_NOT_FOUND")
if (err.code === 'MODULE_NOT_FOUND')
return true;

@@ -488,3 +501,3 @@ if ([

].some((msg) => {
return err.message.indexOf(msg) > -1;
return err.message.indexOf(msg) > -1 || (err.message.toLocaleLowerCase()).indexOf(msg.toLowerCase()) > -1;
}))

@@ -501,4 +514,4 @@ return true;

exports.isDriverNotSupportedError = isDriverNotSupportedError;
exports.exposeErrAndResultFromSyncMethod = FxORMCore.Utils.exposeErrAndResultFromSyncMethod;
exports.throwErrOrCallabckErrResult = FxORMCore.Utils.throwErrOrCallabckErrResult;
exports.catchBlocking = FxORMCore.catchBlocking;
exports.takeAwayResult = FxORMCore.takeAwayResult;
function doWhenErrIs(compare, callback, err) {

@@ -552,5 +565,5 @@ if (!err || util.isEmpty(compare))

else {
var p = m.allProperties[k];
let p = m.allProperties[k];
if (p && p.type === 'date') {
var v = opt[k];
let v = opt[k];
if (!util.isDate(v)) {

@@ -561,3 +574,3 @@ if (util.isNumber(v) || util.isString(v))

comps.forEach(c => {
var v1 = v[c];
let v1 = v[c];
if (Array.isArray(v1)) {

@@ -579,5 +592,11 @@ v1.forEach((v2, i) => {

}
function filterWhereConditionsInput(conditions, m) {
/**
* @description do some mutation for field-value in conditions
*
* @param conditions
* @param host
*/
function filterWhereConditionsInput(conditions, host) {
if (typeof conditions === 'object') {
filter_date_for_where_conditions(conditions, m);
filter_date_for_where_conditions(conditions, host);
}

@@ -584,0 +603,0 @@ return conditions;

{
"name": "@fxjs/orm",
"version": "1.12.1",
"version": "1.13.0",
"description": "",

@@ -32,20 +32,12 @@ "main": "lib",

"ci-mysql": "npm run build && cross-env ORM_PROTOCOL=mysql npm run test",
"ci-sqlite": "npm run build && cross-env ORM_PROTOCOL=sqlite npm run test"
"ci-sqlite": "npm run build && cross-env ORM_PROTOCOL=sqlite npm run test",
"ci-postgres": "npm run build && cross-env ORM_PROTOCOL=postgres npm run test"
},
"ci": {
"type": "travis, appveyor",
"version": [
"0.28.0",
"0.29.0",
"0.30.0",
"0.31.0"
]
},
"dependencies": {
"@fibjs/enforce": "^0.1.1",
"@fxjs/db-driver": "^0.1.0",
"@fxjs/knex": "^0.3.0",
"@fxjs/orm-core": "^0.1.0",
"@fxjs/sql-ddl-sync": "^0.7.1",
"@fxjs/sql-query": "^0.7.1",
"@fxjs/db-driver": "^0.2.0",
"@fxjs/knex": "^0.3.1",
"@fxjs/orm-core": "^0.2.0",
"@fxjs/sql-ddl-sync": "^0.8.0",
"@fxjs/sql-query": "^0.8.0",
"@types/knex": "^0.16.1",

@@ -59,4 +51,3 @@ "fib-pool": "^1.6.0",

"devDependencies": {
"@fibjs/ci": "^2.2.0",
"@fibjs/types": "^0.31.0",
"@fibjs/types": "^0.34.1",
"@types/lodash.clonedeep": "^4.5.6",

@@ -87,3 +78,3 @@ "@types/lodash.flatten": "^4.4.6",

},
"gitHead": "74745692c599fa73dfa67fbbaeeba87a29f5dc40"
"gitHead": "2f11deea2592a9a9919dfdde51ec2b3586fc93f5"
}
/// <reference types="@fibjs/types" />
import type { FxOrmCommon } from '../../Typo/_common';
import type { FxOrmDb } from '../../Typo/Db';
declare const Driver: typeof import("@fxjs/db-driver/typings/built-ins/base.class").MySQLDriver;
declare const Driver: typeof import("@fxjs/db-driver/typings/built-ins/driver-mysql").default;
export declare class Database extends Driver implements FxOrmDb.DatabaseBase<Class_MySQL> {

@@ -6,0 +6,0 @@ eventor: Class_EventEmitter;

/// <reference types="@fibjs/types" />
import type { FxOrmCommon } from '../../Typo/_common';
import type { FxOrmDb } from '../../Typo/Db';
declare const Driver: typeof import("@fxjs/db-driver/typings/built-ins/base.class").SQLiteDriver;
declare const Driver: typeof import("@fxjs/db-driver/typings/built-ins/driver-sqlite").default;
export declare class Database extends Driver implements FxOrmDb.DatabaseBase_SQLite {

@@ -6,0 +6,0 @@ eventor: Class_EventEmitter;

import "./mysql";
import "./postgres";
import "./sqlite";

@@ -34,5 +34,5 @@ /// <reference types="@fibjs/enforce" />

export declare function connectSync(opts?: string | FxDbDriverNS.DBConnectionConfig): FxOrmNS.ORMLike;
export declare function connect<T = any>(uri?: string | FxDbDriverNS.DBConnectionConfig, cb?: FxOrmCoreCallbackNS.ExecutionCallback<IDbDriver<T>>): FxOrmNS.ORMLike;
export declare function connect<T extends IDbDriver.ISQLConn = any>(uri?: string | FxDbDriverNS.DBConnectionConfig, cb?: FxOrmCoreCallbackNS.ExecutionCallback<IDbDriver<T>>): FxOrmNS.ORMLike;
export declare const ORM: FxOrmNS.ORMConstructor;
export declare const ErrorCodes: FxOrmError.PredefineErrorCodes;
export declare const addAdapter: (name: string, constructor: FxOrmDMLDriver.DMLDriverConstructor) => void;

@@ -8,3 +8,3 @@ /// <reference types="@fibjs/types" />

}
interface DatabaseBase<ConnType = any> extends IDbDriver<ConnType> {
interface DatabaseBase<T extends IDbDriver.IConnTypeEnum = IDbDriver.IConnTypeEnum> extends IDbDriver<T> {
eventor: Class_EventEmitter;

@@ -15,4 +15,4 @@ query: {

connect: {
(cb?: FxOrmCommon.GenericCallback<ConnType>): void;
(): ConnType;
(cb?: FxOrmCommon.GenericCallback<T>): void;
(): T;
};

@@ -25,3 +25,3 @@ }

}
interface DatabaseBase_PostgreSQL extends DatabaseBase {
interface DatabaseBase_PostgreSQL extends DatabaseBase<IDbDriver.ISQLConn> {
}

@@ -28,0 +28,0 @@ type AGGREGATION_METHOD_COMMON = "ABS" | "ROUND" | "AVG" | "MIN" | "MAX" | "SUM" | "COUNT" | "DISTINCT";

@@ -30,3 +30,3 @@ /// <reference types="@fibjs/types" />

}
interface DMLDriver<ConnType = any> {
interface DMLDriver<ConnType extends IDbDriver.ISQLConn = IDbDriver.ISQLConn> {
readonly db: FxOrmDb.DatabaseBase<ConnType>;

@@ -45,3 +45,3 @@ readonly config: FxOrmDb.DatabaseBase<ConnType>['config'];

};
readonly ddlDialect: FxOrmSqlDDLSync__Dialect.Dialect;
readonly ddlDialect: FxOrmSqlDDLSync__Dialect.Dialect<IDbDriver.ISQLConn>;
doSync<T = any>(opts?: FxOrmDMLShared.SyncOptions): this;

@@ -139,2 +139,5 @@ doDrop<T = any>(opts?: FxOrmDMLShared.DropOptions): this;

db: FxOrmDb.DatabaseBase<Class_MySQL>;
config: DMLDriver['config'] & {
timezone: string;
};
aggregate_functions: (FxOrmDb.AGGREGATION_METHOD_MYSQL | FxOrmDb.AGGREGATION_METHOD_TUPLE__MYSQL)[];

@@ -148,2 +151,5 @@ }

db: FxOrmDb.DatabaseBase_PostgreSQL;
config: DMLDriver['config'] & {
timezone: string;
};
aggregate_functions: (FxOrmDb.AGGREGATION_METHOD_POSTGRESQL)[];

@@ -157,5 +163,8 @@ }

db: FxOrmDb.DatabaseBase_SQLite;
config: DMLDriver['config'] & {
timezone: string;
};
aggregate_functions: (FxOrmDb.AGGREGATION_METHOD_SQLITE)[];
}
type DefaultSqlDialect = FxOrmSqlDDLSync__Dialect.Dialect;
type DefaultSqlDialect = FxOrmSqlDDLSync__Dialect.Dialect<IDbDriver.ISQLConn>;
}

@@ -162,0 +171,0 @@ export declare namespace FxOrmDMLShared {

@@ -34,2 +34,5 @@ import type { FxOrmSqlDDLSync__Column, FxOrmSqlDDLSync__Driver } from "@fxjs/sql-ddl-sync";

}
/**
* @deprecated use Record<string, NormalizedProperty> instead
*/
interface NormalizedPropertyHash {

@@ -36,0 +39,0 @@ [key: string]: NormalizedProperty;

@@ -52,2 +52,15 @@ /// <reference types="@fibjs/types" />

export declare function getRealPath(path_str: string, stack_index?: number): string;
/**
* @description rename a field name in <dataIn> according to the name map in <properties>
* @example
* ```
* dataIn: { a: 1, b: 2 };
* properties: { a: { mapsTo: 'a1' }, b: { mapsTo: 'b' } };
* -->
* result: { a1: 1, b: 2 };
* ```
*
* @param dataIn
* @param properties
*/
export declare function transformPropertyNames(dataIn: FxOrmInstance.InstanceDataPayload, properties: FxOrmProperty.NormalizedPropertyHash | FxOrmModel.ModelPropertyDefinition): FxOrmInstance.InstanceDataPayload;

@@ -66,4 +79,4 @@ export declare function transformOrderPropertyNames(order: FxOrmQuery.ChainFindOptions['order'], properties: FxOrmProperty.NormalizedPropertyHash): FxSqlQuery.OrderNormalizedResult[];

export declare function isDriverNotSupportedError(err: FxOrmError.ExtendedError): boolean;
export declare const exposeErrAndResultFromSyncMethod: typeof FxORMCore.Utils.exposeErrAndResultFromSyncMethod;
export declare const throwErrOrCallabckErrResult: typeof FxORMCore.Utils.throwErrOrCallabckErrResult;
export declare const catchBlocking: typeof FxORMCore.Utils.exposeErrAndResultFromSyncMethod;
export declare const takeAwayResult: typeof FxORMCore.Utils.throwErrOrCallabckErrResult;
export declare function doWhenErrIs(compare: {

@@ -77,3 +90,11 @@ message?: string;

export declare function is_model_conjunctions_key(k: string): boolean;
export declare function filterWhereConditionsInput(conditions: FxSqlQuerySubQuery.SubQueryConditions, m: FxOrmModel.Model): FxSqlQuerySubQuery.SubQueryConditions;
/**
* @description do some mutation for field-value in conditions
*
* @param conditions
* @param host
*/
export declare function filterWhereConditionsInput(conditions: FxSqlQuerySubQuery.SubQueryConditions, host: {
allProperties: FxOrmProperty.NormalizedPropertyHash;
}): FxSqlQuerySubQuery.SubQueryConditions;
export declare function addUnwritableProperty(obj: any, property: string, value: any, propertyConfiguration?: PropertyDescriptor): void;

@@ -80,0 +101,0 @@ export declare function addHiddenUnwritableMethodToInstance(instance: FxOrmInstance.Instance, method_name: 'save' | 'saveSync' | string, fn: Function, propertyConfiguration?: PropertyDescriptor): void;

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