3.0.25 • Published 2 years ago

node-jql v3.0.25

Weekly downloads
712
License
Apache-2.0
Repository
github
Last release
2 years ago

node-jql

Documentation

Type

type Type = 'string'|'number'|'boolean'|'object'|'Date'|'Array'|'any'

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

IExpression

new ResultColumn(IResultColumn)
new ResultColumn(IExpression|string, string?)

// [expression] AS [$as]
{
  "expression": IExpression,
  "$as": string|undefined
}

IFromTable

IQuery
IJoinClause

new FromTable(IFromTable)
new FromTable(string|IQuery|[string, string], ...IJoinClause[])
new FromTable(string|IQuery|[string, string], string, ...IJoinClause[])

// [database].[table] AS [$as]
{
  "database": string|undefined,
  "table": string|IQuery|IRemoteTable,
  "$as": string|undefined,
  "joinClauses": IJoinClause[]|IJoinClause|undefined
}

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

IExpression

new OrderBy(IOrderBy)
new OrderBy(IExpression|string, 'ASC'|'DESC'?)

// ORDER BY [expression] [order], [expression] [order], ...
{
  "expression": IExpression,
  "order": 'ASC'|'DESC'|undefined
}

ILimitOffset

IExpression

new LimitOffset(ILimitOffset)
new LimitOffset(IValue|number, IValue|number?)

// LIMIT [$limit] OFFSET [$offset]
{
  "$limit": IValue|number,
  "$offset": IValue|number|undefined,
}

IExpression


** classname is a required field in IExpression that specifies the class of the Expression

ICaseExpression

IExpression

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
}

IColumnsExpression

IColumnExpression

// column with table specified
new ColumnsExpression(IColumnsExpression)
new ColumnsExpression(IColumnExpression[])

// ([table].[name], ...)
{
  "columns": IColumnExpression[]
}

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

IExpression

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

Type

new Unknown(IUnknown?)
new Unknown(...Type[])

// ?
{
  "type": Type[]|Type|undefined
}

IValue

Type

new Value(IValue)
new Value(any)

// [value]
{
  "type": Type[]|Type|undefined,
  "value": any
}

IRaw

new Raw(IRaw|string) // aka new Keyword(IRaw|string)

// [sql]
{
  "sql": string
}

IConditionalExpression


extends IExpression

IBetweenExpression

IExpression

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

IExpression

new BinaryExpression(IBinaryExpression)
new BinaryExpression(IExpression|any, operator, IExpression|any?)

// [left] [operator] [right]
{
  "left": IExpression|any,
  "operator": '='|'<>'|'<'|'<='|'>'|'>=',
  "right": IExpression|any|undefined
}

IExistsExpression

IQuery

new ExistsExpression(IExistsExpression)
new ExistsExpression(IQuery, boolean?)

// [$not] EXISTS [query]
{
  "$not": boolean|undefined,
  "query": IQuery
}

IGroupedExpressions

IExpression

new AndExpressions(IGroupedExpressions)
new AndExpressions(IExpression[])

new OrExpressions(IGroupedExpressions)
new OrExpressions(IExpression[])

// ([expression] AND/OR [expression] ...)
{
  "expressions": IExpression[]
}

Phrase

IGroupedExpressions

new Phrase(IGroupedExpressions)
new Phrase(IExpression[])

// [expression] [expression] ...

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

IExpression

new IsNullExpression(IIsNullExpression)
new IsNullExpression(IExpression|any, boolean)

// [left] IS [$not] NULL
{
  "left": IExpression|any,
  "$not": boolean|undefined
}

ILikeExpression

IExpression

new LikeExpression(ILikeExpression)
new LikeExpression(IExpression|any, boolean, IUnknown|string?)

// [left] [$not] LIKE [right]
{
  "left": IExpression|any,
  "$not": boolean|undefined,
  "right": IUnknown|string|undefined
}

IRegexpExpression

IExpression

new RegexpExpression(IRegexpExpression)
new RegexpExpression(IExpression|any, boolean, IUnknown|Regexp|string?)

// [left] [$not] REGEXP [right]
{
  "left": IExpression|any,
  "$not": boolean|undefined,
  "right": IUnknown|Regexp|string|undefined
}
3.0.24

2 years ago

3.0.25

2 years ago

3.0.22

3 years ago

3.0.21

3 years ago

3.0.20

3 years ago

3.0.17

3 years ago

3.0.18

3 years ago

3.0.19

3 years ago

3.0.13

3 years ago

3.0.16

3 years ago

3.0.14

3 years ago

3.0.15

3 years ago

3.0.12

3 years ago

3.0.11

3 years ago

3.0.10

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.0-rc.95

3 years ago

2.0.0-rc.94

4 years ago

2.0.0-rc.93

4 years ago

2.0.0-rc.92

4 years ago

2.0.0-rc.91

4 years ago

2.0.0-rc.90

4 years ago

2.0.0-rc.88

4 years ago

2.0.0-rc.89

4 years ago

2.0.0-rc.87

4 years ago

2.0.0-rc.86

4 years ago

2.0.0-rc.85

4 years ago

2.0.0-rc.84

4 years ago

2.0.0-rc.83

4 years ago

2.0.0-rc.82

4 years ago

2.0.0-rc.81

4 years ago

2.0.0-rc.80

4 years ago

2.0.0-rc.79

4 years ago

2.0.0-rc.73

4 years ago

2.0.0-rc.72

4 years ago

2.0.0-rc.71

4 years ago

2.0.0-rc.70

4 years ago

2.0.0-rc.69

4 years ago

2.0.0-rc.68

4 years ago

2.0.0-rc.67

4 years ago

2.0.0-rc.66

4 years ago

2.0.0-rc.65

4 years ago

2.0.0-rc.64

4 years ago

2.0.0-rc.63

5 years ago

2.0.0-rc.62

5 years ago

2.0.0-rc.61

5 years ago

2.0.0-rc.60

5 years ago

2.0.0-rc.59

5 years ago

2.0.0-rc.58

5 years ago

2.0.0-rc.57

5 years ago

2.0.0-rc.56

5 years ago

2.0.0-rc.55

5 years ago

2.0.0-rc.54

5 years ago

2.0.0-rc.53

5 years ago

2.0.0-rc.52

5 years ago

2.0.0-rc.51

5 years ago

2.0.0-rc.50

5 years ago

2.0.0-rc.49

5 years ago

2.0.0-rc.48

5 years ago

2.0.0-rc.47

5 years ago

2.0.0-rc.46

5 years ago

2.0.0-rc.45

5 years ago

2.0.0-rc.44

5 years ago

2.0.0-rc.43

5 years ago

2.0.0-rc.42

5 years ago

2.0.0-rc.41

5 years ago

2.0.0-rc.40

5 years ago

2.0.0-rc.39

5 years ago

2.0.0-rc.38

5 years ago

2.0.0-rc.37

5 years ago

2.0.0-rc.36

5 years ago

2.0.0-rc.35

5 years ago

2.0.0-rc.34

5 years ago

2.0.0-rc.33

5 years ago

2.0.0-rc.32

5 years ago

2.0.0-rc.31

5 years ago

2.0.0-rc.30

5 years ago

2.0.0-rc.29

5 years ago

2.0.0-rc.28

5 years ago

2.0.0-rc.27

5 years ago

2.0.0-rc.26

5 years ago

2.0.0-rc.25

5 years ago

2.0.0-rc.24

5 years ago

2.0.0-rc.23

5 years ago

2.0.0-rc.22

5 years ago

2.0.0-rc.21

5 years ago

2.0.0-rc.20

5 years ago

2.0.0-rc.18

5 years ago

2.0.0-rc.17

5 years ago

1.6.2

5 years ago

2.0.0-rc.16

5 years ago

2.0.0-rc.15

5 years ago

2.0.0-rc.14

5 years ago

2.0.0-rc.13

5 years ago

2.0.0-rc.12

5 years ago

2.0.0-rc.11

5 years ago

2.0.0-rc.10

5 years ago

2.0.0-rc.9

5 years ago

2.0.0-rc.8

5 years ago

2.0.0-rc.7

5 years ago

2.0.0-rc.6

5 years ago

2.0.0-rc.5

5 years ago

2.0.0-rc.4

5 years ago

2.0.0-rc.3

5 years ago

2.0.0-rc.2

5 years ago

2.0.0-rc.1

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.14

5 years ago

1.5.13

5 years ago

1.5.12

5 years ago

1.5.11

5 years ago

1.5.9

5 years ago

1.5.8

5 years ago

1.5.7

5 years ago

1.5.6

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.1.0

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago