Socket
Socket
Sign inDemoInstall

@simplysm/sd-orm-common

Package Overview
Dependencies
Maintainers
1
Versions
584
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simplysm/sd-orm-common - npm Package Compare versions

Comparing version 3.5.52 to 3.5.54

22

dist-browser/Queryable.js

@@ -134,2 +134,23 @@ "use strict";

};
Queryable.prototype.pivot = function (valueFwd, pivotFwd, pivotKeys) {
var valueColumn = valueFwd(this._entity);
var pivotColumn = pivotFwd(this._entity);
var entity = tslib_1.__assign({}, this._entity);
for (var _i = 0, pivotKeys_1 = pivotKeys; _i < pivotKeys_1.length; _i++) {
var pivotKey = pivotKeys_1[_i];
if (valueColumn instanceof QueryUnit_1.QueryUnit) {
entity[pivotKey] = new QueryUnit_1.QueryUnit(valueColumn.type, this.db.qb.wrap("TBL" + (this._as !== undefined ? "." + this._as : "")) + "." + this.db.qb.wrap(pivotKey));
}
else {
throw new sd_core_common_1.NotImplementError();
}
}
var result = new Queryable(this.db, this, entity);
result._def.pivot = {
valueColumn: this.db.qh.getQueryValue(valueColumn),
pivotColumn: this.db.qh.getQueryValue(pivotColumn),
pivotKeys: pivotKeys
};
return result;
};
Queryable.prototype.groupBy = function (fwd) {

@@ -373,2 +394,3 @@ var _this = this;

result.limit = this._def.limit;
result.pivot = this._def.pivot;
result.groupBy = this._def.groupBy;

@@ -375,0 +397,0 @@ result.having = this._def.having;

@@ -209,2 +209,7 @@ "use strict";

q += "\n";
if (def.pivot) {
q += "PIVOT (SUM(" + this.getQueryOfQueryValue(def.pivot.valueColumn) + ") FOR " + this.getQueryOfQueryValue(def.pivot.pivotColumn);
q += " IN (" + def.pivot.pivotKeys.map(function (key) { return _this.wrap(key); }).join(", ") + ")) as " + def.as;
q += "\n";
}
if (def.join && def.join.length > 0) {

@@ -211,0 +216,0 @@ for (var _e = 0, _f = def.join; _e < _f.length; _e++) {

@@ -159,2 +159,7 @@ /// <reference types="node" />

limit?: [number, number];
pivot?: {
valueColumn: TQueryBuilderValue;
pivotColumn: TQueryBuilderValue;
pivotKeys: string[];
};
select?: {

@@ -275,2 +280,7 @@ [key: string]: TQueryBuilderValue;

limit?: [number, number];
pivot?: {
valueColumn: TQueryBuilderValue;
pivotColumn: TQueryBuilderValue;
pivotKeys: string[];
};
}

@@ -277,0 +287,0 @@ export declare type NonTQueryValuePropertyNames<T> = {

1

dist/Queryable.d.ts

@@ -24,2 +24,3 @@ import { DbContext } from "./DbContext";

limit(skip: number, take: number): Queryable<D, T>;
pivot<V extends TQueryValue, P extends string>(valueFwd: ((entity: TEntity<T>) => TEntityValue<V>), pivotFwd: ((entity: TEntity<T>) => TEntityValue<P>), pivotKeys: P[]): Queryable<D, T & Record<P, V>>;
groupBy(fwd: (entity: TEntity<T>) => TEntityValue<TQueryValue>[]): Queryable<D, T>;

@@ -26,0 +27,0 @@ having(predicate: (entity: TEntity<T>) => TEntityValueOrQueryableOrArray<D, any>[]): Queryable<D, T>;

@@ -130,2 +130,22 @@ "use strict";

}
pivot(valueFwd, pivotFwd, pivotKeys) {
const valueColumn = valueFwd(this._entity);
const pivotColumn = pivotFwd(this._entity);
const entity = Object.assign({}, this._entity);
for (const pivotKey of pivotKeys) {
if (valueColumn instanceof QueryUnit_1.QueryUnit) {
entity[pivotKey] = new QueryUnit_1.QueryUnit(valueColumn.type, `${this.db.qb.wrap(`TBL${this._as !== undefined ? `.${this._as}` : ""}`)}.${this.db.qb.wrap(pivotKey)}`);
}
else {
throw new sd_core_common_1.NotImplementError();
}
}
const result = new Queryable(this.db, this, entity);
result._def.pivot = {
valueColumn: this.db.qh.getQueryValue(valueColumn),
pivotColumn: this.db.qh.getQueryValue(pivotColumn),
pivotKeys
};
return result;
}
groupBy(fwd) {

@@ -346,2 +366,3 @@ const result = new Queryable(this.db, this);

result.limit = this._def.limit;
result.pivot = this._def.pivot;
result.groupBy = this._def.groupBy;

@@ -348,0 +369,0 @@ result.having = this._def.having;

@@ -236,2 +236,7 @@ "use strict";

q += "\n";
if (def.pivot) {
q += `PIVOT (SUM(${this.getQueryOfQueryValue(def.pivot.valueColumn)}) FOR ${this.getQueryOfQueryValue(def.pivot.pivotColumn)}`;
q += ` IN (${def.pivot.pivotKeys.map(key => this.wrap(key)).join(", ")})) as ${def.as}`;
q += "\n";
}
if (def.join && def.join.length > 0) {

@@ -238,0 +243,0 @@ for (const joinDef of def.join) {

4

dist/QueryHelper.d.ts

@@ -29,4 +29,4 @@ import { ISelectQueryDef, TDbDateSeparator, TEntityValue, TEntityValueOrQueryableOrArray, TQueryBuilderValue, TQueryValue } from "./commons";

is(where: TQueryBuilderValue[]): QueryUnit<boolean>;
dateDiff<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T>, to: TEntityValue<T>): QueryUnit<number>;
dateAdd<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T>, value: TEntityValue<number>): QueryUnit<T>;
dateDiff<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T | 0>, to: TEntityValue<T | 0>): QueryUnit<number>;
dateAdd<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T | 0>, value: TEntityValue<number>): QueryUnit<T>;
ifNull<S extends TQueryValue, T extends TQueryValue>(source: TEntityValue<S>, ...targets: TEntityValue<T>[]): QueryUnit<S extends undefined ? T : S>;

@@ -33,0 +33,0 @@ case<T extends TQueryValue>(predicate: TEntityValue<boolean | Boolean> | TQueryBuilderValue, then: TEntityValue<T>): CaseQueryHelper<T>;

{
"name": "@simplysm/sd-orm-common",
"version": "3.5.52",
"version": "3.5.54",
"description": "심플리즘 패키지 - ORM 모듈 (browser/node)",

@@ -13,4 +13,4 @@ "author": "김석래",

"dependencies": {
"@simplysm/sd-core-common": "3.5.52"
"@simplysm/sd-core-common": "3.5.54"
}
}

@@ -184,2 +184,7 @@ import { DateOnly, DateTime, StripTypeWrap, Time, Type, TypeWrap, Uuid } from "@simplysm/sd-core-common";

limit?: [number, number];
pivot?: {
valueColumn: TQueryBuilderValue;
pivotColumn: TQueryBuilderValue;
pivotKeys: string[];
};

@@ -324,2 +329,7 @@ select?: { [key: string]: TQueryBuilderValue };

limit?: [number, number];
pivot?: {
valueColumn: TQueryBuilderValue;
pivotColumn: TQueryBuilderValue;
pivotKeys: string[];
};
}

@@ -326,0 +336,0 @@

@@ -207,2 +207,28 @@ import { DbContext } from "./DbContext";

public pivot<V extends TQueryValue, P extends string>(valueFwd: ((entity: TEntity<T>) => TEntityValue<V>),
pivotFwd: ((entity: TEntity<T>) => TEntityValue<P>),
pivotKeys: P[]): Queryable<D, T & Record<P, V>> {
const valueColumn = valueFwd(this._entity);
const pivotColumn = pivotFwd(this._entity);
const entity: any = { ...this._entity };
for (const pivotKey of pivotKeys) {
if (valueColumn instanceof QueryUnit) {
entity[pivotKey] = new QueryUnit<any>(valueColumn.type, `${this.db.qb.wrap(`TBL${this._as !== undefined ? `.${this._as}` : ""}`)}.${this.db.qb.wrap(pivotKey)}`);
}
else {
throw new NotImplementError();
}
}
const result = new Queryable(this.db, this, entity);
result._def.pivot = {
valueColumn: this.db.qh.getQueryValue(valueColumn),
pivotColumn: this.db.qh.getQueryValue(pivotColumn),
pivotKeys
};
return result as any;
}
public groupBy(fwd: (entity: TEntity<T>) => TEntityValue<TQueryValue>[]): Queryable<D, T> {

@@ -513,2 +539,3 @@ const result = new Queryable(this.db, this);

result.limit = this._def.limit;
result.pivot = this._def.pivot;
result.groupBy = this._def.groupBy;

@@ -515,0 +542,0 @@ result.having = this._def.having;

@@ -341,2 +341,3 @@ import {

// FROM
if (def.from instanceof Array) {

@@ -366,2 +367,10 @@ q += `FROM (\n`;

// PIVOT
if (def.pivot) {
q += `PIVOT (SUM(${this.getQueryOfQueryValue(def.pivot.valueColumn)}) FOR ${this.getQueryOfQueryValue(def.pivot.pivotColumn)}`;
q += ` IN (${def.pivot.pivotKeys.map(key => this.wrap(key)).join(", ")})) as ${def.as}`;
q += "\n";
}
// JOIN

@@ -368,0 +377,0 @@

@@ -202,10 +202,10 @@ import {

public dateDiff<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T>, to: TEntityValue<T>): QueryUnit<number> {
public dateDiff<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T | 0>, to: TEntityValue<T | 0>): QueryUnit<number> {
return new QueryUnit<number>(Number, ["DATEDIFF(", separator, ", ", this.getQueryValue(from), ", ", this.getQueryValue(to), ")"]);
}
public dateAdd<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T>, value: TEntityValue<number>): QueryUnit<T> {
public dateAdd<T extends DateTime | DateOnly | Time>(separator: TDbDateSeparator, from: TEntityValue<T | 0>, value: TEntityValue<number>): QueryUnit<T> {
const type = SdOrmUtils.getQueryValueType(from);
return new QueryUnit(type, ["DATEADD(", separator, ", ", this.getQueryValue(value), ", ", this.getQueryValue(from), ")"]);
return new QueryUnit(type, ["DATEADD(", separator, ", ", this.getQueryValue(value), ", ", this.getQueryValue(from), ")"]) as any;
}

@@ -212,0 +212,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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