Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractBuilder<T>

A base class that facilitates building database queries using a fluent interface. This can be specialized by child-classes to yield query results of the given type T.

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

Properties

Protected constraints

constraints: Constraint[] = []

Constraints applied to this query.

Protected Readonly databaseService

databaseService: DatabaseService

Protected Optional rawSql

rawSql: string

Raw SQL to use instead. Overrides builder methods.

Protected Optional registeredConnection

registeredConnection: Connection

The connection on which the query should be executed.

Protected registeredDistinct

registeredDistinct: boolean = false

If true, the query should refer to distinct records.

Protected registeredFields

registeredFields: SpecifiedField[] = []

The fields to query from the table.

Protected registeredGroupings

registeredGroupings: string[] = []

Array of SQL group-by clauses.

Protected registeredOrders

registeredOrders: OrderStatement[] = []

Array of SQL order-by clauses.

Protected Optional registeredSkip

registeredSkip: number

The number of records to skip before the result set.

Protected Optional registeredTake

registeredTake: number

The max number of records to include in the result set.

Protected Optional source

source: QuerySource

The source table to query from.

Accessors

Private appClassApplication

appliedConstraints

appliedDistinction

  • get appliedDistinction(): boolean

appliedFields

appliedGroupings

  • get appliedGroupings(): string[]

appliedOrder

appliedPagination

  • get appliedPagination(): { skip: undefined | number; take: undefined | number }
  • Get the skip/take values of this query.

    Returns { skip: undefined | number; take: undefined | number }

    • skip: undefined | number
    • take: undefined | number

appliedRawSql

  • get appliedRawSql(): Maybe<string>

querySource

Methods

Protected app

clearFields

clone

connection

Protected container

Private createConstraint

delete

distinct

exists

  • exists(): Promise<boolean>

field

fields

finalize

first

  • first(): Promise<undefined | T>

from

get

getBoundMethod

  • getBoundMethod(methodName: string): (...args: any[]) => any
  • Get the method with the given name from this class, bound to this class.

    Parameters

    • methodName: string

    Returns (...args: any[]) => any

    function

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

Abstract getNewInstance

Abstract getResultIterable

groupBy

insert

  • Insert the given rows into the table for this query, returning the fields specified in this query.

    example
    const rows = [
     { name: 'A' },
     { name: 'B' },
    ]
    
    query.table('my_table')
     .returning('id', 'name')
     .insert(rows)
    

    This is equivalent to:

    INSERT INTO my_table (name)
    VALUES ('A'), ('B')
    RETURNING id, name
    

    Parameters

    • rowOrRows: {} | {}[]

    Returns Promise<QueryResult>

iterator

limit

Protected make

  • make<T>(target: any, ...parameters: any[]): T

notDistinct

offset

orWhere

orWhereIn

orWhereNot

orWhereNotIn

orWhereRaw

orderBy

orderByAscending

orderByDescending

page

  • Apply skip() and take() calls to retrieve the records that should appear on the pageNum page, assuming each page has pageSize many records.

    Parameters

    • pageNum: number = 1
    • pageSize: number = 20

    Returns AbstractBuilder<T>

raw

returning

select

skip

table

take

update

  • Run an UPDATE query for all rows matched by this query, setting the given data.

    example
    query.table('my_table').update({ my_col: 4 })
    

    This is equivalent to:

    UPDATE TO my_table
    SET
     my_col = 4
    

    Parameters

    Returns Promise<QueryResult>

where

whereIn

whereNot

whereNotIn

whereRaw

Extollo Logo

extollo (v. latin) - to lift up, to elevate

Extollo is a free & libre application framework in TypeScript.