npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-jql

v3.0.25

Published

For building SQL in object-oriented structure

Downloads

446

Readme

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
}