Options
All
  • Public
  • Public/Protected
  • All
Menu
     

Class QRY

Creates SQL queries with integrity in mind

Hierarchy

  • any
    • QRY

Index

Constructors

constructor

  • new QRY(debug?: boolean): QRY
  • Creates SQL queries with integrity in mind

    Parameters

    • Optional debug: boolean

    Returns QRY

Accessors

IN

  • get IN(): this
  • An IN(...items) operator

    Returns this

    The QRY instance chain

EX

  • get EX(): this
  • An EXISTS(QRY) operator

    Returns this

    The QRY instance chain

EQ

  • get EQ(): this
  • A = operator

    Returns this

    The QRY instance chain

NE

  • get NE(): this
  • A <> operator

    Returns this

    The QRY instance chain

GT

  • get GT(): this
  • A > operator

    Returns this

    The QRY instance chain

LT

  • get LT(): this
  • A < operator

    Returns this

    The QRY instance chain

GE

  • get GE(): this
  • A >= operator

    Returns this

    The QRY instance chain

LE

  • get LE(): this
  • A <= operator

    Returns this

    The QRY instance chain

LK

  • get LK(): this
  • A LIKE operator

    Returns this

    The QRY instance chain

RX

  • get RX(): this
  • A REGEXP operator

    Returns this

    The QRY instance chain

RL

  • get RL(): this
  • A RLIKE operator

    Returns this

    The QRY instance chain

BT

  • get BT(): this
  • A BETWEEN operator

    Returns this

    The QRY instance chain

IS

  • get IS(): this
  • A IS operator

    Returns this

    The QRY instance chain

NOT

  • get NOT(): this
  • A NOT operator

    Returns this

    The QRY instance chain

Methods

SLC

  • SLC(): this
  • Begin a SELECT statement

    Returns this

    The QRY instance chain

INS

  • INS(table: string, ...columns?: string): this
  • Begin a INSERT statement

    Parameters

    • table: string

      The table recieving INSERTS

    • Optional Rest ...columns: string

      The columns recieving VALUES

    Returns this

    The QRY instance chain

UPD

  • UPD(table: string, ...options: string): this
  • Begin a UPDATE statement

    Parameters

    • table: string

      The table recieving UPDATES

    • Rest ...options: string

      An optional identifer and database for the table

    Returns this

    The QRY instance chain

DEL

  • DEL(): this
  • Begin a DELETE statement

    Returns this

    The QRY instance chain

VALUES

  • VALUES(...values: string[]): this
  • Designate VALUES of which to INSERT

    Parameters

    • Rest ...values: string[]

      The VALUES lists for each INSERT

    Returns this

    The QRY instance chain

SET

  • SET(sets: object): this
  • Designate columns and values of which to UPDATE

    Parameters

    • sets: object

      An object of columns and the values they'll be SET to

      • [key: string]: any

    Returns this

    The QRY instance chain

FROM

  • FROM(table: string | QRY, identifier?: string, database?: string): this
  • Designate first table the query pertains to

    Parameters

    • table: string | QRY

      The name of the FROM table, or a QRY object

    • Optional identifier: string

      The AS identifier; if needed

    • Optional database: string

      The database of this table; if needed

    Returns this

    The QRY instance chain

JOIN

  • JOIN(kind: string, table: string | QRY, identifier?: string, on?: Object, database?: string): this
  • Designate any a table to JOIN in the query

    Parameters

    • kind: string

      The type of JOIN (INNER|LEFT|RIGHT|FULL)

    • table: string | QRY

      The name of the JOIN table, or a QRY object

    • Optional identifier: string

      The AS identifier; if needed

    • Optional on: Object

      The JOIN condition; if needed

    • Optional database: string

      The database of this table; if needed

    Returns this

    The QRY instance chain

UNI

  • UNI(ALL?: boolean): this
  • Designate a table UNION in the query

    Parameters

    • Optional ALL: boolean

      If true; this will be UNION ALL (removes duplicate)

    Returns this

    The QRY instance chain

WHR

  • WHR(what?: string | number, is?: string | number, to?: string | number): this
  • The WHERE clause

    Parameters

    • Optional what: string | number

      The left side of the clause

    • Optional is: string | number

      The operator to judge the clause by

    • Optional to: string | number

      The right side of the clause

    Returns this

    The QRY instance chain

AND

  • AND(what?: string | number, is?: string | number, to?: string | number): this
  • An AND clause

    Parameters

    • Optional what: string | number

      The left side of the clause

    • Optional is: string | number

      The operator to judge the clause by

    • Optional to: string | number

      The right side of the clause

    Returns this

    The QRY instance chain

OR

  • OR(what?: string | number, is?: string | number, to?: string | number): this
  • An OR clause

    Parameters

    • Optional what: string | number

      The left side of the clause

    • Optional is: string | number

      The operator to judge the clause by

    • Optional to: string | number

      The right side of the clause

    Returns this

    The QRY instance chain

ON

  • ON(what?: string | number, is?: string | number, to?: string | number): this
  • An ON clause

    Parameters

    • Optional what: string | number

      The left side of the clause

    • Optional is: string | number

      The operator to judge the clause by

    • Optional to: string | number

      The right side of the clause

    Returns this

    The QRY instance chain

GRP

  • GRP(...columns: string): this
  • A GROUP BY statement

    Parameters

    • Rest ...columns: string

      The columns to GROUP BY

    Returns this

    The QRY instance chain

ORD

  • ORD(...columns: string): this
  • An ORDER BY statement

    Parameters

    • Rest ...columns: string

      The columns to ORDER BY

    Returns this

    The QRY instance chain

LMT

  • LMT(limit: number): this
  • A LIMIT for the query

    Parameters

    • limit: number

      The amount to LIMIT the query by

    Returns this

    The QRY instance chain

OFS

  • OFS(offset: number): this
  • An OFFSET for a LIMIT

    Parameters

    • offset: number

      The OFFSET to start the LIMIT at

    Returns this

    The QRY instance chain

toArgs

  • toArgs(): DCT[]
  • Returns DCT[]

    The raw arguments used for formatting

toString

  • toString(): string
  • Returns string

    A formatted query-string

toSQL

  • toSQL(): string
  • Returns string

    A collapsed query-string

toPretty

  • toPretty(): string
  • Returns string

    A formatted query-string with color

Static test

  • test(): string[]
  • Yields an Array of formatted exmaples

    Returns string[]

    An Array of formatted exmaples