1.0.0-rc.15 • Published 4 years ago
@node-jql/sql-builder v1.0.0-rc.15
node-jql
This library defines only the JSON structure of SQL statements for the in-memory SQL database node-jql-core.
If you are looking for the database core, please visit node-jql-core.
Documentation
Type
type Type = 'string'|'number'|'boolean'|'object'|'Date'|'Array'|'any'
ICreateDatabaseJQL
new CreateDatabaseJQL(ICreateDatabaseJQL)
new CreateDatabaseJQL(string, boolean?, string?)
{
"name": string,
"$ifNotExists": boolean|undefined,
"engine": string|undefined
}
IDropDatabaseJQL
new DropDatabaseJQL(IDropDatabaseJQL)
new DropDatabaseJQL(string, boolean?)
{
"name": string,
"$ifExists": boolean|undefined
}
ICreateTableJQL
new CreateTableJQL(ICreateTableJQL)
new CreateTableJQL([string, string]|string, IColumn[], boolean|undefined, string[]|string|undefined, ...string[])
new CreateTableJQL(true, [string, string]|string, IColumn[], boolean|undefined, string[]|string|undefined, ...string[])
{
"$temporary": boolean|undefined,
"database": boolean|undefined,
"name": string,
"$ifNotExists": boolean|undefined,
"columns": IColumn[],
"constraints": string[]|undefined,
"options": string[]|undefined,
"$as": IQuery|undefined
}
// IColumn
new Column(IColumn)
new Column(string, Type, boolean?, ...string[])
{
"name": string,
"type": Type,
"nullable": boolean|undefined,
"defValue": any|undefined,
"options": string[]|string|undefined
}
IInsertJQL
new InsertJQL(IInsertJQL)
new InsertJQL([string, string]|string, IQuery, string[])
new InsertJQL([string, string]|string, ...any[])
{
"database": string|undefined,
"name": string,
"values": any[]|undefined,
"columns": string[]|undefined,
"query": IQuery|undefined
}
IDropTableJQL
new DropTableJQL(IDropTableJQL)
new DropTableJQL(string, boolean?)
new DropTableJQL(true, string, boolean?)
{
"$temporary": boolean|undefined,
"name": string,
"$ifExists": boolean|undefined
}
ICreateFunctionJQL
new CreateFunctionJQL(ICreateFunctionJQL)
new CreateFunctionJQL(string, string|Function, Type?, ...Type)
new CreateFunctionJQL(true, string, string|Function, Type?, ...Type)
{
"aggregate": boolean|undefined,
"name": string,
"fn": string|Function,
"parameters": Type[]|undefined,
"type": Type|undefined
}
IDropFunctionJQL
new DropFunctionJQL(IDropFunctionJQL)
new DropFunctionJQL(string, boolean?)
{
"name": string,
"$ifExists": boolean|undefined
}
PredictJQL
new PredictJQL(...IJQL[])
IQuery
IResultColumn
IFromTable
IConditionalExpression
IGroupBy
IOrderBy
ILimitOffset
// full query
new Query(IQuery)
// normal query - SELECT ... FROM ... WHERE
new Query(IResultColumn[], IFromTable|string, ...IConditionalExpression[])
// simple query - SELECT * FROM [database].[table]
new Query(string|null, string)
// simple query - SELECT * FROM [table]
new Query(string)
{
// DISTINCT
"$distinct": boolean|undefined,
// SELECT ...
"$select": IResultColumn[]|IResultColumn|string|undefined,
// FROM ... JOIN ...
"$from": IFromTable[]|IFromTable|string|undefined,
// WHERE ...
"$where": IConditionalExpression[]|IConditionalExpression|undefined,
// GROUP BY ...
"$group": IGroupBy|string|undefined,
// ORDER BY ...
"$order": IOrderBy[]|IOrderBy|string|undefined,
// LIMIT ... OFFSET ...
"$limit": ILimitOffset|number|undefined
}
IResultColumn
new ResultColumn(IResultColumn)
new ResultColumn(IExpression|string, string?)
// [expression] AS [$as]
{
"expression": IExpression,
"$as": string|undefined
}
IFromTable
new FromTable(IFromTable)
new FromTable(string|IQuery|IRemoteTable|[string, string], ...IJoinClause[])
new FromTable(string|IQuery|IRemoteTable|[string, string], string, ...IJoinClause[])
// [database].[table] AS [$as]
{
"database": string|undefined,
"table": string|IQuery|IRemoteTable,
"$as": string|undefined,
"joinClauses": IJoinClause[]|IJoinClause|undefined
}
IRemoteTable
extends AxiosRequestConfig
Type
{
"columns": Array<{ name: string, type?: Type }>
}
IJoinClause
IFromTable
IConditionalExpression
new JoinClause(IJoinClause)
new JoinClause('INNER'|'CROSS'|'LEFT'|'RIGHT'|'FULL', IFromTable|string, ...IConditionalExpression[])
// [operator] JOIN [tableOrSubquery] AS [$on]
{
"operator": 'INNER'|'CROSS'|'LEFT'|'RIGHT'|'FULL'|undefined,
"tableOrSubquery": IFromTable|string
"$on": IConditionalExpression[]|IConditionalExpression|undefined
}
IGroupBy
IExpression
IConditionalExpression
new GroupBy(IGroupBy)
new GroupBy(IExpression|string)
new GroupBy(Array<IExpression|string>, ...IConditionalExpression[])
// GROUP BY [expressions] HAVING [$having]
{
"expressions": IExpression[]|IExpression,
"$having": IConditionalExpression[]|IConditionalExpression|undefined
}
IOrderBy
new OrderBy(IOrderBy)
new OrderBy(IExpression|string, 'ASC'|'DESC'?)
// ORDER BY [expression] [order], [expression] [order], ...
{
"expression": IExpression,
"order": 'ASC'|'DESC'|undefined
}
ILimitOffset
new LimitOffset(ILimitOffset)
new LimitOffset(IExpression|number, IExpression|number?)
// LIMIT [$limit] OFFSET [$offset]
{
"$limit": IExpression|number,
"$offset": IExpression|number|undefined,
}
IExpression
** classname
is a required field in IExpression
that specifies the class of the Expression
ICaseExpression
new CaseExpression(ICaseExpression)
new CaseExpression(ICase[], IExpression?)
// CASE [cases] ELSE [$else]
{
"cases": ICase[]|ICase,
"$else": IExpression|undefined
}
// ICase
// WHEN [$when] THEN [$then]
{
"$when": IConditionalExpression,
"$then": any
}
IColumnExpression
// column with table specified
new ColumnExpression(IColumnExpression)
new ColumnExpression(string|null, string)
// column only
new ColumnExpression(string)
// [table].[name]
{
"table": string|undefined,
"name": string
}
IFunctionExpression
supports most of the SQL built-in functions and works similarly
IParameterExpression
new FunctionExpression(IFunctionExpression)
new FunctionExpression(name, ...any[])
// [name]([parameters])
{
"name": string,
"parameters": any[]|any|undefined
}
IMathExpression
new MathExpression(IMathExpression)
new MathExpression(IExpression|any, '+'|'-'|'*'|'/'|'%'|'MOD'|'DIV', IExpression|any?)
// [left] [operator] [right]
{
"left": IExpression|any,
"operator": '+'|'-'|'*'|'/'|'%'|'MOD'|'DIV',
"right": IExpression|any|undefined
}
IParameterExpression
new ParameterExpression(IParameterExpression)
new ParameterExpression(string|null, IExpression|any, string?)
// [prefix] [expression] [suffix]
// e.g. prefix is used for cases like `COUNT(DISTINCT id)`
{
"prefix": string|undefined,
"expression": IExpression|any,
"suffix": string|undefined
}
IUnknown
new Unknown(IUnknown?)
new Unknown(...Type[])
// ?
{
"type": Type[]|Type|undefined
}
IValue
new Value(IValue)
new Value(any)
// [value]
{
"type": Type[]|Type|undefined,
"value": any
}
IConditionalExpression
extends IExpression
IBetweenExpression
new BetweenExpression(IBetweenExpression)
new BetweenExpression(IExpression|any, boolean, IExpression|any?, IExpression|any?)
// [left] [$not] BETWEEN [start] AND [end]
{
"left": IExpression|any,
"$not": boolean|undefined,
"start": IExpression|any|undefined,
"end": IExpression|any|undefined
}
IBinaryExpression
new BinaryExpression(IBinaryExpression)
new BinaryExpression(IExpression|any, operator, IExpression|any?)
// [left] [operator] [right]
{
"left": IExpression|any,
"operator": '='|'<>'|'<'|'<='|'>'|'>=',
"right": IExpression|any|undefined
}
IExistsExpression
new ExistsExpression(IExistsExpression)
new ExistsExpression(IQuery, boolean?)
// [$not] EXISTS [query]
{
"$not": boolean|undefined,
"query": IQuery
}
IGroupedExpressions
new AndExpressions(IGroupedExpressions)
new AndExpressions(IConditionalExpression[])
new OrExpressions(IGroupedExpressions)
new OrExpressions(IConditionalExpression[])
// ([expression] AND/OR [expression] ...)
{
"expressions": IConditionalExpression[]
}
IInExpression
IExpression
IUnknown
IQuery
IValue
new InExpression(IInExpression)
new InExpression(IExpression|any, boolean, IUnknown|IQuery|IValue|any[]?)
// [left] [$not] IN [right]
{
"left": IExpression|any,
"$not": boolean|undefined,
"operator": 'IN',
"right": IUnknown|IQuery|IValue|any[]|undefined
}
IIsNullExpression
new IsNullExpression(IIsNullExpression)
new IsNullExpression(IExpression|any, boolean)
// [left] IS [$not] NULL
{
"left": IExpression|any,
"$not": boolean|undefined
}
ILikeExpression
new LikeExpression(ILikeExpression)
new InExpression(IExpression|any, boolean, IUnknown|string?)
// [left] [$not] [operator] [right]
{
"left": IExpression|any,
"$not": boolean|undefined,
"operator": 'LIKE'|'REGEXP'|undefined,
"right": IUnknown|string|undefined
}
1.0.0-rc.15
4 years ago
1.0.0-rc.14
4 years ago
1.0.0-rc.13
4 years ago
1.0.0-rc.12
4 years ago
1.0.0-rc.11
4 years ago
1.0.0-rc.10
4 years ago
1.0.0-rc.9
4 years ago
1.0.0-rc.8
4 years ago
1.0.0-rc.7
4 years ago
1.0.0-rc.6
4 years ago
1.0.0-rc.5
4 years ago
1.0.0-rc.3
4 years ago
1.0.0-rc.4
4 years ago
1.0.0-rc.2
4 years ago
1.0.0-rc.1
4 years ago