zol
Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

AggrCols

AggrCols: object

Type declaration

LeftCols

LeftCols: object

Type declaration

MakeCols

MakeCols: object

Type declaration

MakeTable

MakeTable: object & object

TableDeclareCols

TableDeclareCols: object

Type declaration

Functions

aggregate

  • aggregate<s, a>(q: Q<s>, s: function): MakeCols<s, a>
  • Type parameters

    • s

    • a: any

    Parameters

    Returns MakeCols<s, a>

arbitrary

  • An arbitrary column, useful for queries where the values of the returned rows are not important, such as in exists queries.

    Type parameters

    • s

    Returns Col<s, Arbitrary>

avg

  • avg<s>(col: Col<s, number>): Aggr<s, number | null>
  • Type parameters

    • s

    Parameters

    • col: Col<s, number>

    Returns Aggr<s, number | null>

booleanCol

  • booleanCol<s>(val: boolean): Col<s, boolean>
  • Type parameters

    • s

    Parameters

    • val: boolean

    Returns Col<s, boolean>

count

  • count<s, a>(col: Col<s, a>): Aggr<s, number>
  • Type parameters

    • s

    • a

    Parameters

    • col: Col<s, a>

    Returns Aggr<s, number>

declareTable

  • Type parameters

    • Req: any

    • Def: any

    Parameters

    Returns Table<Req, Def>

defaultValue

  • Can be used in insert and update operations, to set the value of a column to its default value.

    This can only be used on table columns that have been declared as "default-able" when the table was declared using declareTable.

    This is like using the DEFAULT keyword in SQL.

    Returns DefaultValue

delete_

  • delete_<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, pred: function): Promise<number>
  • Delete rows of a table

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • pred: function

      Which rows should be deleted (the WHERE clause)

    Returns Promise<number>

    number of rows deleted

distinct

  • distinct<s, a>(q: Q<s>, query: function): MakeCols<s, a>
  • Type parameters

    • s

    • a: any

    Parameters

    Returns MakeCols<s, a>

e

  • e<s, a>(lhs: Col<s, a>, op: "=", rhs: Col<s, a>): Col<s, boolean>
  • e<s, a>(lhs: Col<s, a>, op: "!=", rhs: Col<s, a>): Col<s, boolean>
  • e<s, a>(lhs: Col<s, a>, op: ">", rhs: Col<s, a>): Col<s, boolean>
  • e<s, a>(lhs: Col<s, a>, op: "<", rhs: Col<s, a>): Col<s, boolean>
  • e<s, a>(lhs: Col<s, a>, op: ">=", rhs: Col<s, a>): Col<s, boolean>
  • e<s, a>(lhs: Col<s, a>, op: "<=", rhs: Col<s, a>): Col<s, boolean>
  • e<s>(lhs: Col<s, boolean>, op: "AND", rhs: Col<s, boolean>): Col<s, boolean>
  • e<s>(lhs: Col<s, boolean>, op: "OR", rhs: Col<s, boolean>): Col<s, boolean>
  • e<s>(lhs: Col<s, number>, op: "+", rhs: Col<s, number>): Col<s, number>
  • e<s>(lhs: Col<s, number>, op: "-", rhs: Col<s, number>): Col<s, number>
  • e<s>(lhs: Col<s, number>, op: "*", rhs: Col<s, number>): Col<s, number>
  • e<s>(lhs: Col<s, number>, op: "/", rhs: Col<s, number>): Col<s, number>
  • e<s>(lhs: Col<s, string>, op: "||", rhs: Col<s, string>): Col<s, string>
  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • op: "="
    • rhs: Col<s, a>

    Returns Col<s, boolean>

  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • op: "!="
    • rhs: Col<s, a>

    Returns Col<s, boolean>

  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • op: ">"
    • rhs: Col<s, a>

    Returns Col<s, boolean>

  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • op: "<"
    • rhs: Col<s, a>

    Returns Col<s, boolean>

  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • op: ">="
    • rhs: Col<s, a>

    Returns Col<s, boolean>

  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • op: "<="
    • rhs: Col<s, a>

    Returns Col<s, boolean>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, boolean>
    • op: "AND"
    • rhs: Col<s, boolean>

    Returns Col<s, boolean>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, boolean>
    • op: "OR"
    • rhs: Col<s, boolean>

    Returns Col<s, boolean>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, number>
    • op: "+"
    • rhs: Col<s, number>

    Returns Col<s, number>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, number>
    • op: "-"
    • rhs: Col<s, number>

    Returns Col<s, number>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, number>
    • op: "*"
    • rhs: Col<s, number>

    Returns Col<s, number>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, number>
    • op: "/"
    • rhs: Col<s, number>

    Returns Col<s, number>

  • Type parameters

    • s

    Parameters

    • lhs: Col<s, string>
    • op: "||"
    • rhs: Col<s, string>

    Returns Col<s, string>

exists

  • exists<s>(subquery: function): Col<s, boolean>
  • Does the subquery have at least one row?

    SQL equivalent: EXISTS

    Type parameters

    • s

    Parameters

    • subquery: function

      The subquery should return arbitrary (since the values, of the resulting rows in unimportant).

    Returns Col<s, boolean>

groupBy

  • Type parameters

    • s

    • a

    Parameters

    Returns Aggr<Inner<s>, a>

ifNull

  • ifNull<s, a>(replacement: Col<s, a>, nullable: Col<s, a | null>): Col<s, a>
  • If the second value is null, return the first value. Otherwise return the second value.

    Type parameters

    • s

    • a

    Parameters

    • replacement: Col<s, a>
    • nullable: Col<s, a | null>

    Returns Col<s, a>

ifThenElse

  • ifThenElse<s, a>(if_: Col<s, boolean>, then: Col<s, a>, else_: Col<s, a>): Col<s, a>
  • Perform a conditional on a column

    SQL equivalent: CASE

    Type parameters

    • s

    • a

    Parameters

    • if_: Col<s, boolean>
    • then: Col<s, a>
    • else_: Col<s, a>

    Returns Col<s, a>

ilike

  • ilike<s>(str: Col<s, string>, pattern: string): Col<s, boolean>
  • ilike<s>(str: Col<s, string>, pattern: Col<s, string>): Col<s, boolean>
  • Returns true if the string matches the supplied pattern, using case-insensitive matching

    SQL equivalent: ILIKE

    Type parameters

    • s

    Parameters

    • str: Col<s, string>

      The string to be matched against

    • pattern: string

      The pattern to use. May use special characters '%' and '_'

    Returns Col<s, boolean>

  • Returns true if the string matches the supplied pattern, using case-insensitive matching

    SQL equivalent: ILIKE

    Type parameters

    • s

    Parameters

    • str: Col<s, string>

      The string to be matched against

    • pattern: Col<s, string>

      The pattern to use. May use special characters '%' and '_'

    Returns Col<s, boolean>

inList

  • inList<s, a>(lhs: Col<s, a>, rhs: Col<s, a>[]): Col<s, boolean>
  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • rhs: Col<s, a>[]

    Returns Col<s, boolean>

inQuery

  • inQuery<s, a>(lhs: Col<s, a>, rhs: function): Col<s, boolean>
  • Type parameters

    • s

    • a

    Parameters

    • lhs: Col<s, a>
    • rhs: function
        • (q: Q<s>): Col<s, a>
        • Parameters

          • q: Q<s>

          Returns Col<s, a>

    Returns Col<s, boolean>

inner

  • inner<s, a>(q: Q<s>, query: function): MakeCols<s, a>
  • Explicitly create an inner query.

    Sometimes it's handy, for performance reasons and otherwise, to perform a subquery and restrict only that query before adding the result of the query to the result set, instead of first adding the query to the result set and restricting the whole result set afterwards.

    Type parameters

    • s

    • a: any

    Parameters

    Returns MakeCols<s, a>

innerJoin

  • innerJoin<s, a>(q: Q<s>, s: function, pred: function): MakeCols<s, a>

insert

  • insert<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>): Promise<void>
  • Insert a single row into a table

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>

    Returns Promise<void>

insertMany

  • insertMany<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>[]): Promise<void>
  • Insert multiple rows into a table

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>[]

    Returns Promise<void>

insertManyOnConflictDoNothing

  • insertManyOnConflictDoNothing<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>[], conflictTarget: ConflictTarget<Req & Def>): Promise<number>
  • Insert multiple rows into a table, with an ON CONFLICT DO NOTHING clause

    Type parameters

    • Req: any

    • Def: any

    Parameters

    Returns Promise<number>

    The number of rows inserted

insertManyOnConflictDoNothingReturning

  • insertManyOnConflictDoNothingReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>[], conflictTarget: ConflictTarget<Req & Def>, returning: function): Promise<Ret[]>
  • Insert multiple rows into a table, with an ON CONFLICT DO NOTHING clause, and with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>[]
    • conflictTarget: ConflictTarget<Req & Def>
    • returning: function

    Returns Promise<Ret[]>

insertManyOnConflictDoUpdate

  • insertManyOnConflictDoUpdate<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>[], conflictTarget: ConflictTarget<Req & Def>, onConflictPred: function, onConflictUpdate: function): Promise<number>
  • Insert multiple rows into a table, with an ON CONFLICT DO UPDATE clause

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>[]
    • conflictTarget: ConflictTarget<Req & Def>
    • onConflictPred: function

      Which rows should be updated (the WHERE clause)

    • onConflictUpdate: function

      A function that returns the new values for a row.

                          You may use <a href="index.html#defaultvalue">defaultValue</a> on "default-able" columns.
      
                          Should have an explicit annotation of the return type, in order to catch excess properties.
                          See: <https://github.com/Microsoft/TypeScript/issues/7547#issuecomment-218017839>

    Returns Promise<number>

    The number of newly inserted rows + the number of updated rows

insertManyOnConflictDoUpdateReturning

  • insertManyOnConflictDoUpdateReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>[], conflictTarget: ConflictTarget<Req & Def>, onConflictPred: function, onConflictUpdate: function, returning: function): Promise<Ret[]>
  • Insert multiple rows into a table, with an ON CONFLICT DO UPDATE clause, and with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    Returns Promise<Ret[]>

insertManyReturning

  • insertManyReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>[], returning: function): Promise<Ret[]>
  • Insert multiple rows into a table, with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>[]
    • returning: function

    Returns Promise<Ret[]>

insertOnConflictDoNothing

  • insertOnConflictDoNothing<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>, conflictTarget: ConflictTarget<Req & Def>): Promise<boolean>
  • Insert a single row into a table, with an ON CONFLICT DO NOTHING clause

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>
    • conflictTarget: ConflictTarget<Req & Def>

    Returns Promise<boolean>

    true if the row was inserted

insertOnConflictDoNothingReturning

  • insertOnConflictDoNothingReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>, conflictTarget: ConflictTarget<Req & Def>, returning: function): Promise<Ret>
  • Insert a single row into a table, with an ON CONFLICT DO NOTHING clause, and with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>
    • conflictTarget: ConflictTarget<Req & Def>
    • returning: function

    Returns Promise<Ret>

insertOnConflictDoUpdate

  • insertOnConflictDoUpdate<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>, conflictTarget: ConflictTarget<Req & Def>, onConflictPred: function, onConflictUpdate: function): Promise<boolean>
  • Insert a single row into a table, with an ON CONFLICT DO UPDATE clause

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>
    • conflictTarget: ConflictTarget<Req & Def>
    • onConflictPred: function

      Which rows should be updated (the WHERE clause)

    • onConflictUpdate: function

      A function that returns the new values for a row.

                          You may use <a href="index.html#defaultvalue">defaultValue</a> on "default-able" columns.
      
                          Should have an explicit annotation of the return type, in order to catch excess properties.
                          See: <https://github.com/Microsoft/TypeScript/issues/7547#issuecomment-218017839>

    Returns Promise<boolean>

    If a new row was inserted returns true.

        If a conflicting row already existed but was updated returns true.
    
        If a conflicting row already existed and was not updated returns false.

insertOnConflictDoUpdateReturning

  • insertOnConflictDoUpdateReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>, conflictTarget: ConflictTarget<Req & Def>, onConflictPred: function, onConflictUpdate: function, returning: function): Promise<Ret>
  • Insert a single row into a table, with an ON CONFLICT DO UPDATE clause, and with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    Returns Promise<Ret>

insertReturning

  • insertReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, rowValues: MakeTable<Req, Def>, returning: function): Promise<Ret>
  • Insert a single row into a table, with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • rowValues: MakeTable<Req, Def>
    • returning: function

    Returns Promise<Ret>

isNotNull

  • isNotNull<s, a>(col: Col<s, a | null>): Col<s, boolean>
  • Is the given column not null?

    This is like SQL's IS NOT NULL check

    isNotNull(c) is equivalent to not(isNull(c))

    Type parameters

    • s

    • a

    Parameters

    • col: Col<s, a | null>

    Returns Col<s, boolean>

isNull

  • isNull<s, a>(col: Col<s, a | null>): Col<s, boolean>
  • Is the given column null?

    This is like SQL's IS NULL check

    Type parameters

    • s

    • a

    Parameters

    • col: Col<s, a | null>

    Returns Col<s, boolean>

leftJoin

  • leftJoin<s, a>(q: Q<s>, s: function, pred: function): LeftCols<s, a>

like

  • like<s>(str: Col<s, string>, pattern: string): Col<s, boolean>
  • like<s>(str: Col<s, string>, pattern: Col<s, string>): Col<s, boolean>
  • Returns true if the string matches the supplied pattern

    SQL equivalent: LIKE

    Type parameters

    • s

    Parameters

    • str: Col<s, string>

      The string to be matched against

    • pattern: string

      The pattern to use. May use special characters '%' and '_'

    Returns Col<s, boolean>

  • Returns true if the string matches the supplied pattern

    SQL equivalent: LIKE

    Type parameters

    • s

    Parameters

    • str: Col<s, string>

      The string to be matched against

    • pattern: Col<s, string>

      The pattern to use. May use special characters '%' and '_'

    Returns Col<s, boolean>

limit

  • limit<s, a>(q: Q<s>, from: number, to: number, query: function): MakeCols<s, a>

matchNull

  • matchNull<s, s2, a, b>(nullable: Col<s, a | null>, replacement: Col<s, b>, f: function): Col<s, b>
  • Applies the given function to the given nullable column where it isn't null, and returns the given default value where it is.

    Type parameters

    • s

    • s2

    • a

    • b

    Parameters

    • nullable: Col<s, a | null>

      A nullable column to match against

    • replacement: Col<s, b>

      This is the value that will be returned if the nullable column is NULL

    • f: function

      This function will be called if the nullable column is not null, and its result will be returned

        • (col: Col<s2, a>): Col<s2, b>
        • Parameters

          • col: Col<s2, a>

          Returns Col<s2, b>

    Returns Col<s, b>

max

  • max<s, a>(col: Col<s, a>): Aggr<s, a | null>
  • Type parameters

    • s

    • a

    Parameters

    • col: Col<s, a>

    Returns Aggr<s, a | null>

min

  • min<s, a>(col: Col<s, a>): Aggr<s, a | null>
  • Type parameters

    • s

    • a

    Parameters

    • col: Col<s, a>

    Returns Aggr<s, a | null>

not

  • not<s, a>(col: Col<s, a | null>): Col<s, boolean>
  • Boolean negation.

    This is like SQL's NOT operator

    Type parameters

    • s

    • a

    Parameters

    • col: Col<s, a | null>

    Returns Col<s, boolean>

nullCol

  • nullCol<s>(): Col<s, null>
  • Type parameters

    • s

    Returns Col<s, null>

numberCol

  • numberCol<s>(val: number): Col<s, number>
  • Type parameters

    • s

    Parameters

    • val: number

    Returns Col<s, number>

order

  • order<s, a>(q: Q<s>, col: Col<s, a>, order: Order): void
  • Type parameters

    • s

    • a

    Parameters

    Returns void

query

  • query<t>(sqlTag: string | undefined, conn: Client, q: function): Promise<t[]>
  • Type parameters

    • t: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • q: function

    Returns Promise<t[]>

queryOne

  • queryOne<t>(sqlTag: string | undefined, conn: Client, q: function): Promise<t>
  • Similar to query, but when you are certain that the query will always return exactly 1 row.

    For example: COUNT(*) style queries

    Type parameters

    • t: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • q: function

    Returns Promise<t>

queryOneOrNone

  • queryOneOrNone<t>(sqlTag: string | undefined, conn: Client, q: function): Promise<t | null>
  • Similar to query, but when you are certain that the query will always return either 1 row or 0 rows.

    For example: queries that are restricted on some primary key

    Type parameters

    • t: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • q: function

    Returns Promise<t | null>

queryStreaming

  • queryStreaming<t>(sqlTag: string | undefined, conn: Client, q: function, rowChunkSize?: number): Promise<StreamingRows<t>>
  • Perform a query, but stream the results rather than loading them all into memory.

    After you call this function, you must call the readAllRows function, and you must call it while the connection is still open (and don't close the connection until it completes).

    Type parameters

    • t: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • q: function
    • Optional rowChunkSize: number

      How many rows to read and process during each iteration

    Returns Promise<StreamingRows<t>>

restrict

  • restrict<s>(q: Q<s>, expr: Col<s, boolean>): void
  • Type parameters

    • s

    Parameters

    • q: Q<s>
    • expr: Col<s, boolean>

    Returns void

restrictEq

  • restrictEq<s, a>(q: Q<s>, lhs: Col<s, a>, rhs: Col<s, a>): void
  • A shortcut that calls restrict comparing two columns for equality.

    restrictEq(q, x, y) is equivalent to restrict(q, e(x, "=", y))

    Type parameters

    • s

    • a

    Parameters

    • q: Q<s>
    • lhs: Col<s, a>
    • rhs: Col<s, a>

    Returns void

select

  • Type parameters

    • s

    • a: any

    • b: any

    Parameters

    Returns MakeCols<s, a & b>

selectValues

  • Query an ad hoc table. Each element in the given list represents one row in the ad hoc table.

    Type parameters

    • s

    • a: any

    Parameters

    Returns MakeCols<s, a>

suchThat

  • suchThat<s, a>(q: Q<s>, query: function, pred: function): MakeCols<s, a>
  • Create and filter an inner query, before adding it to the current result set.

    suchThat(q, query, p) is generally more efficient than const x = query(q); restrict(pred(x)); return x;

    Type parameters

    • s

    • a: any

    Parameters

    Returns MakeCols<s, a>

sum

  • sum<s>(col: Col<s, number>): Aggr<s, number>
  • Type parameters

    • s

    Parameters

    • col: Col<s, number>

    Returns Aggr<s, number>

textCol

  • textCol<s>(str: string): Col<s, string>
  • Type parameters

    • s

    Parameters

    • str: string

    Returns Col<s, string>

update

  • update<Req, Def>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, pred: function, upd: function): Promise<number>
  • Update rows of a table

    Type parameters

    • Req: any

    • Def: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • pred: function

      Which rows should be updated (the WHERE clause)

    • upd: function

      A function that returns the new values for a row.

             You may use <a href="index.html#defaultvalue">defaultValue</a> on "default-able" columns.
      
             Should have an explicit annotation of the return type, in order to catch excess properties.
             See: <https://github.com/Microsoft/TypeScript/issues/7547#issuecomment-218017839>

    Returns Promise<number>

    number of rows updated

updateReturning

  • updateReturning<Req, Def, Ret>(sqlTag: string | undefined, conn: Client, table: Table<Req, Def>, pred: function, upd: function, returning: function): Promise<Ret[]>
  • Update rows of a table, with a RETURNING clause

    Type parameters

    • Req: any

    • Def: any

    • Ret: any

    Parameters

    • sqlTag: string | undefined

      Will be injected as a comment into the SQL that is sent to the server. Useful for identifying the query during log analysis and performance analysis

    • conn: Client
    • table: Table<Req, Def>
    • pred: function

      Which rows should be updated (the WHERE clause)

    • upd: function

      A function that returns the new values for a row.

             You may use <a href="index.html#defaultvalue">defaultValue</a> on "default-able" columns.
      
             Should have an explicit annotation of the return type, in order to catch excess properties.
             See: <https://github.com/Microsoft/TypeScript/issues/7547#issuecomment-218017839>
    • returning: function

    Returns Promise<Ret[]>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc