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.3 to 1.9.4

lib/orm/entry/Patch/plugin.js

4

@types/instance.d.ts

@@ -70,2 +70,4 @@ /// <reference path="DMLDriver.d.ts" />

type InstanceEventType =
'ready' | 'save' | 'beforeRemove' | 'remove'
interface Instance extends FxOrmSynchronous.SynchronizedInstance {

@@ -80,3 +82,3 @@ save(): Instance;

};
on(event: string, callback: FxOrmNS.GenericCallback<any>): Instance;
on(event: InstanceEventType, callback: FxOrmNS.GenericCallback<any>): Instance;
save(callback?: FxOrmNS.VoidCallback): Instance;

@@ -83,0 +85,0 @@ save(data: { [property: string]: any; }, callback?: FxOrmNS.VoidCallback): Instance;

@@ -152,4 +152,5 @@ /// <reference types="fibjs" />

new (orm?: ORM, opts?: PluginOptions): Plugin
// prototype: Plugin
prototype: Plugin
}
type PluginConstructCallback = (orm: ORM, opts: PluginOptions) => Plugin
interface Plugin {

@@ -181,3 +182,5 @@ // (connection: FibORM, proto: any, opts: any, cb: Function): any

use(plugin: PluginConstructor, options?: PluginOptions): ORM;
use: {
(plugin: /* PluginConstructor | */PluginConstructCallback, options?: PluginOptions): ORM;
}

@@ -184,0 +187,0 @@ define(name: string, properties: FxOrmModel.ModelPropertyDefinitionHash, opts?: FxOrmModel.ModelOptions): FxOrmModel.Model;

v1.9.3 / 2019-03-26
v1.9.4 / 2019-03-27
==================
* better implements for patch on Model and model's hooks.
v1.9.3 / 2019-03-26
===================
* Release v1.9.3
* add helpers; fix lack of patch to instance in afterLoad hook.

@@ -6,0 +12,0 @@ * code clean and add some TODO.

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

cb.call(this, this);
_oldHook = _oldHook.bind(this);
if (_oldHook) {

@@ -131,0 +132,0 @@ if (_oldHook.length > 0) {

@@ -18,2 +18,3 @@ /// <reference lib="es2017" />

const AggregateFunctions = require("./AggregateFunctions");
const utils_1 = require("./Patch/utils");
const AvailableHooks = [

@@ -47,2 +48,4 @@ "beforeCreate", "afterCreate",

m_opts.hooks[hook] = cb;
if (hook === 'afterLoad' || hook === 'afterAutoFetch')
utils_1.patchHooksInModelOptions(m_opts, [hook]);
}

@@ -49,0 +52,0 @@ return this;

@@ -160,3 +160,3 @@ const util = require("util");

}
var plugin = new plugin_const(this, opts || {});
var plugin = plugin_const(this, opts || {});
if (typeof plugin.define === "function") {

@@ -163,0 +163,0 @@ for (let k in this.models) {

const url = require("url");
const util = require("util");
const utils_1 = require("./utils");
const plugin_1 = require("./plugin");
module.exports = function (connection) {

@@ -21,13 +22,3 @@ const conn = util.sync(connection);

utils_1.patchDriver(orm.driver);
var def = orm.define;
orm.define = function (name, properties, opts) {
if (opts !== undefined) {
opts = util.clone(opts);
if (opts.hooks !== undefined)
opts.hooks = util.clone(opts.hooks);
}
var m = def.call(this, name, properties, opts);
utils_1.patchModel(m, opts);
return m;
};
orm.use(plugin_1.default);
orm.begin = function () {

@@ -34,0 +25,0 @@ return this.driver.db.conn.begin();

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

}
function is_ichainfind(o) {
return o.model && o.model.allProperties;
}
// hook find, patch result
function patchResult(o) {
var old_func = o.find;
var m = o.model || o;
if (!old_func)
return;
var m = is_ichainfind(o) ? o.model : o;
// keyof FxSqlQuerySql.DetailedQueryWhereCondition

@@ -161,11 +166,11 @@ var comps = ['val', 'from', 'to'];

exports.patchAggregate = patchAggregate;
function patchModel(m, opts) {
opts = opts || {};
opts.hooks = opts.hooks || {};
Helpers_1.preReplaceHook(m, opts, 'afterLoad', function (instance) {
patchObject(instance);
function patchHooksInModelOptions(opts, hooks = ['afterLoad', 'afterAutoFetch']) {
hooks.forEach(hook => {
Helpers_1.prependHook(opts.hooks, hook, function () {
patchObject(this);
});
});
Helpers_1.preReplaceHook(m, opts, 'afterAutoFetch', function (instance) {
patchObject(instance);
});
}
exports.patchHooksInModelOptions = patchHooksInModelOptions;
function patchModelAfterDefine(m) {
patchResult(m);

@@ -192,3 +197,3 @@ patchSync(m, [

}
exports.patchModel = patchModel;
exports.patchModelAfterDefine = patchModelAfterDefine;
function patchIChainFindLikeRs(rs, opts = {}) {

@@ -195,0 +200,0 @@ const { exlude_keys = [], new_callback_generator = null } = opts || {};

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

@@ -5,0 +5,0 @@ "main": "lib",

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