Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sql-ts

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-ts - npm Package Compare versions

Comparing version 4.1.1 to 5.0.0

16

dist/cjs/column.js

@@ -15,8 +15,3 @@ 'use strict';

this.table = config.table;
this.asc = this;
this.alias = undefined;
this.desc = new node_1.OrderByValueNode({
direction: new node_1.TextNode('DESC'),
value: this.toNode()
});
this.isConstant = config.isConstant;

@@ -50,2 +45,13 @@ this.constantValue = config.constantValue;

}
asc() {
return new node_1.OrderByValueNode({
value: this.toNode()
});
}
desc() {
return new node_1.OrderByValueNode({
direction: new node_1.TextNode('DESC'),
value: this.toNode()
});
}
arrayAgg(alias) {

@@ -52,0 +58,0 @@ const context = contextify(this);

@@ -58,5 +58,8 @@ 'use strict';

col.table = this;
if (this[name] === undefined) {
this[name] = col;
col.star = undefined;
const subQuery = this;
if (subQuery[name] === undefined) {
subQuery[name] = col;
}
subQuery.columns.push(col);
}

@@ -63,0 +66,0 @@ }

'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.Table = exports.Sql = void 0;
exports.Sql = void 0;
const tslib_1 = require("tslib");

@@ -12,3 +12,2 @@ const defaults_1 = tslib_1.__importDefault(require("lodash/defaults"));

const table_1 = require("./table");
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return table_1.Table; } });
class Sql {

@@ -15,0 +14,0 @@ constructor(dialect = dialect_1.DEFAULT_DIALECT, config = {}) {

@@ -148,5 +148,2 @@ 'use strict';

}
literal(literal) {
return new node_1.LiteralNode(literal);
}
count(alias) {

@@ -172,4 +169,5 @@ const name = this.alias || this.tableName;

const query = new node_1.Query(this, true);
query.columns = [];
query.alias = alias;
query.join = (other) => {
query.join = function (other) {
return new node_1.JoinNode('INNER', this.toNode(), other.toNode());

@@ -228,12 +226,64 @@ };

}
alter() {
const query = new node_1.Query(this);
query.alter();
return query;
}
create() {
const query = new node_1.Query(this);
query.create();
return query;
}
delete(arg) {
const query = new node_1.Query(this);
query.delete(arg);
return query;
}
drop() {
const query = new node_1.Query(this);
query.drop();
return query;
}
from(...args) {
const query = new node_1.Query(this);
query.from(...args);
return query;
}
limit(count) {
const query = new node_1.Query(this);
query.limit(count);
return query;
}
offset(count) {
const query = new node_1.Query(this);
query.offset(count);
return query;
}
or(object) {
const query = new node_1.Query(this);
query.or(object);
return query;
}
order(...args) {
const query = new node_1.Query(this);
query.order(...args);
return query;
}
truncate() {
const query = new node_1.Query(this);
query.truncate();
return query;
}
update(object) {
const query = new node_1.Query(this);
query.update(object);
return query;
}
where(...args) {
const query = new node_1.Query(this);
query.where(...args);
return query;
}
}
exports.Table = Table;
const queryMethods = ['alter', 'create', 'delete', 'drop', 'from', 'limit', 'offset', 'or', 'order', 'truncate', 'update', 'where'];
queryMethods.forEach((method) => {
Table.prototype[method] = function (...args) {
const query = new node_1.Query(this);
query[method].apply(query, args);
return query;
};
});
//# sourceMappingURL=table.js.map

@@ -32,5 +32,3 @@ import { ColumnNode, IValueExpressionMixin, OrderByValueNode } from './node';

table?: Table<unknown>;
asc: this;
alias?: string;
desc: OrderByValueNode;
dataType?: string;

@@ -65,2 +63,4 @@ _value: any;

as(alias: string): ColumnNode;
asc(): OrderByValueNode;
desc(): OrderByValueNode;
arrayAgg(alias?: string): ColumnNode;

@@ -67,0 +67,0 @@ aggregate(alias: string | undefined, aggregator: string): ColumnNode;

@@ -12,8 +12,3 @@ 'use strict';

this.table = config.table;
this.asc = this;
this.alias = undefined;
this.desc = new OrderByValueNode({
direction: new TextNode('DESC'),
value: this.toNode()
});
this.isConstant = config.isConstant;

@@ -47,2 +42,13 @@ this.constantValue = config.constantValue;

}
asc() {
return new OrderByValueNode({
value: this.toNode()
});
}
desc() {
return new OrderByValueNode({
direction: new TextNode('DESC'),
value: this.toNode()
});
}
arrayAgg(alias) {

@@ -49,0 +55,0 @@ const context = contextify(this);

@@ -5,3 +5,3 @@ import { Node, Query } from '.';

count: Node;
constructor(query: Query<unknown>, type: 'LIMIT' | 'OFFSET', count: any);
constructor(query: Query<unknown>, type: 'LIMIT' | 'OFFSET', count: unknown);
}
import { Node } from '.';
import { INodeable } from '../nodeable';
export declare class ParameterNode extends Node {
static getNodeOrParameterNode(value?: INodeable): Node;
static getNodeOrParameterNode(value?: INodeable | unknown): Node;
isExplicit: boolean;

@@ -6,0 +6,0 @@ private val;

import { CreateIndexNode, DropIndexNode, IAliasMixin, IValueExpressionMixinBase, JoinNode, Node, PrefixUnaryNode } from '.';
import { Column } from '../column';
import { INodeable } from '../nodeable';
import { INodeable, PartialNodeable } from '../nodeable';
import { Table } from '../table';

@@ -9,3 +9,2 @@ export declare class Query<T> extends Node {

alias?: string;
join?: (other: any) => JoinNode;
private whereClause?;

@@ -40,3 +39,3 @@ private insertClause?;

replace(...nodes: Column<unknown>[]): this;
update(object: Partial<T>): this;
update(object: PartialNodeable<T>): this;
parameter(v: any): this;

@@ -56,4 +55,7 @@ delete(table: Table<unknown>[] | Table<unknown> | Partial<T>): this;

forShare(): this;
create(indexName: string): this | CreateIndexNode;
drop(): this | DropIndexNode;
create(): this;
create(indexName: string): CreateIndexNode;
drop(): this;
drop(indexName: string): DropIndexNode;
drop(...columns: Column<unknown>[]): DropIndexNode;
truncate(): this;

@@ -67,4 +69,4 @@ distinct(): this;

renameColumn(oldColumn: Column<unknown> | string, newColumn: Column<unknown> | string): this;
limit(count: any): this;
offset(count: any): this;
limit(count: unknown): this;
offset(count: unknown): this;
exists(): PrefixUnaryNode;

@@ -82,4 +84,10 @@ notExists(): PrefixUnaryNode;

}
export declare type SubQuery<T> = Query<T> & {
[key: string]: Column<unknown>;
declare type SubQueryExtensions<T, C extends object> = {
join: (other: INodeable) => JoinNode;
} & {
columns: Column<unknown>[];
} & {
[P in keyof C]: Column<C[P]>;
};
export declare type SubQuery<T, C extends object> = Query<T> & SubQueryExtensions<T, C>;
export {};

@@ -55,5 +55,8 @@ 'use strict';

col.table = this;
if (this[name] === undefined) {
this[name] = col;
col.star = undefined;
const subQuery = this;
if (subQuery[name] === undefined) {
subQuery[name] = col;
}
subQuery.columns.push(col);
}

@@ -60,0 +63,0 @@ }

@@ -0,1 +1,2 @@

/// <reference types="node" />
import { Node } from './node';

@@ -5,2 +6,5 @@ export interface INodeable {

}
export declare function instanceofINodeable(o: object): o is INodeable;
export declare function instanceofINodeable(o: unknown): o is INodeable;
export declare type PartialNodeable<T> = {
[P in keyof T]?: T[P] | INodeable | Buffer;
};

@@ -5,4 +5,4 @@ import { Column } from './column';

import { ArrayCallNode, FunctionCallNode, IntervalNode, LiteralNode, Query } from './node';
import { Table, TableWithColumns } from './table';
declare class Sql {
import { TableWithColumns } from './table';
export declare class Sql {
functions: functions.StandardFunctions;

@@ -27,2 +27,1 @@ dialect: any;

}
export { Sql, Table };

@@ -9,3 +9,3 @@ 'use strict';

import { Table } from './table';
class Sql {
export class Sql {
constructor(dialect = DEFAULT_DIALECT, config = {}) {

@@ -69,3 +69,2 @@ this.setDialect(dialect, config);

}
export { Sql, Table };
//# sourceMappingURL=sql.js.map

@@ -1,6 +0,5 @@

/// <reference types="node" />
import { Column } from './column';
import { ColumnDefinition, TableDefinition } from './configTypes';
import { ColumnNode, ForeignKeyNode, JoinNode, LiteralNode, Node, OrderByValueNode, Query, SubQuery, TableNode } from './node';
import { INodeable } from './nodeable';
import { ColumnNode, DropIndexNode, ForeignKeyNode, JoinNode, Node, OrderByValueNode, Query, SubQuery, TableNode } from './node';
import { INodeable, PartialNodeable } from './nodeable';
import { Sql } from './sql';

@@ -40,6 +39,5 @@ export declare type TableWithColumns<T> = Table<T> & {

}): ColumnNode[];
literal(literal: any): LiteralNode;
count(alias?: string): ColumnNode;
select(...args: any[]): Query<T>;
subQuery(alias?: string): SubQuery<T>;
subQuery<C extends object>(alias?: string): SubQuery<T, C>;
insert(object: Column<unknown>[] | Column<unknown>): Query<T>;

@@ -58,7 +56,2 @@ insert(object: PartialNodeable<T>[] | PartialNodeable<T>): Query<T>;

indexes(): IndexQuery;
}
declare type PartialNodeable<T> = {
[P in keyof T]?: T[P] | INodeable | Buffer;
};
export interface Table<T> {
alter(): Query<T>;

@@ -83,4 +76,4 @@ create(): Query<T>;

create(indexName?: string): IndexCreationQuery;
drop(indexName: string): Node;
drop(...columns: Column<unknown>[]): Node;
drop(indexName: string): DropIndexNode;
drop(...columns: Column<unknown>[]): DropIndexNode;
}

@@ -87,0 +80,0 @@ interface IndexCreationQuery extends Node {

@@ -6,3 +6,3 @@ 'use strict';

import { leftJoin } from './joiner';
import { ForeignKeyNode, JoinNode, LiteralNode, Query, TableNode } from './node';
import { ForeignKeyNode, JoinNode, Query, TableNode } from './node';
import { Sql } from './sql';

@@ -146,5 +146,2 @@ export class Table {

}
literal(literal) {
return new LiteralNode(literal);
}
count(alias) {

@@ -170,4 +167,5 @@ const name = this.alias || this.tableName;

const query = new Query(this, true);
query.columns = [];
query.alias = alias;
query.join = (other) => {
query.join = function (other) {
return new JoinNode('INNER', this.toNode(), other.toNode());

@@ -226,11 +224,63 @@ };

}
}
const queryMethods = ['alter', 'create', 'delete', 'drop', 'from', 'limit', 'offset', 'or', 'order', 'truncate', 'update', 'where'];
queryMethods.forEach((method) => {
Table.prototype[method] = function (...args) {
alter() {
const query = new Query(this);
query[method].apply(query, args);
query.alter();
return query;
};
});
}
create() {
const query = new Query(this);
query.create();
return query;
}
delete(arg) {
const query = new Query(this);
query.delete(arg);
return query;
}
drop() {
const query = new Query(this);
query.drop();
return query;
}
from(...args) {
const query = new Query(this);
query.from(...args);
return query;
}
limit(count) {
const query = new Query(this);
query.limit(count);
return query;
}
offset(count) {
const query = new Query(this);
query.offset(count);
return query;
}
or(object) {
const query = new Query(this);
query.or(object);
return query;
}
order(...args) {
const query = new Query(this);
query.order(...args);
return query;
}
truncate() {
const query = new Query(this);
query.truncate();
return query;
}
update(object) {
const query = new Query(this);
query.update(object);
return query;
}
where(...args) {
const query = new Query(this);
query.where(...args);
return query;
}
}
//# sourceMappingURL=table.js.map

@@ -8,3 +8,3 @@ {

"description": "SQL Builder",
"version": "4.1.1",
"version": "5.0.0",
"homepage": "https://github.com/charsleysa/node-sql-ts",

@@ -11,0 +11,0 @@ "license": "MIT",

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

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

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