Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueryUpdate

A 'delete' query is used to delete record from one or more tables. The query does support multiple tables but those need to be related (joined). Optional filter can be set for each table used on the query. When executed, all records that match are being deleted - first from child(s) then from parent table.

since

1.1.0

Hierarchy

  • QueryUpdate

Implements

Index

Constructors

Accessors

Methods

Constructors

constructor

  • Creates a delete query for one or more tables of an API connection.

    Parameters

    • conn: Connection
    • table: string

      The name of the table to delete the record from.

    • values: Record

      The field values to set on this table when the query is executed.

    • Optional filter: Filter

      The filter condition for the table.

    Returns QueryUpdate

Accessors

tables

  • The information on tables used on this query.

    Returns IQueryTable[]

Methods

fetch

  • Asynchronously executes the update query and, when fulfilled, returns the updated row(s).

    since

    1.1.0

    Parameters

    • Optional timeout: number

      The query execution timeout (milliseconds).

    Returns Promise<Record | Record[]>

filter

  • Set additional filter for last table added to the query.

    Parameters

    • filter: Filter

      The filter condition to set on the table

    Returns QueryUpdate

    Returns the current query instance (fluent interface).

go

  • go(timeout?: number): Promise<number>
  • Asynchronously executes the delete query and, when fulfilled, returns the number of affected (deleted) rows.

    Parameters

    • Optional timeout: number

      The query execution timeout (milliseconds).

    Returns Promise<number>

join

  • Joins another table to the query.

    Parameters

    • table: string

      The name of the joined table.

    • parent: string

      The parent table to join on.

    • Optional mode: SelectionMode
    • Optional outer: boolean
    • Optional alias: string
    • Optional filter: Filter
    • Optional joinMap: QueryJoinMap

    Returns QueryUpdate

    Returns the current query instance (fluent interface).

on

  • on(parentField: string, childField?: string): QueryUpdate
  • Adds an additional field mapping for the last table joined to the query.

    Parameters

    • parentField: string

      The name of the field in the parent table.

    • Optional childField: string

    Returns QueryUpdate

    Returns the current query instance (fluent interface).

set

  • Set the value to be assigned for a field when the query is executed, this applies for the last table added to the query.

    since

    1.1.0

    Parameters

    • fieldName: string

      The name of the field, use square brackets to specify an array item.

    • value: FieldValue | FieldValue[]

      The value to set for that field.

    • Optional extent: number

    Returns QueryUpdate

    Returns the current query instance (fluent interface).

Static execute

  • execute(connection: Connection, query: IQueryUpdate, fetch?: boolean, timeout?: number): Promise<Record[] | Record | number>
  • Asynchronously executes the update query on the connection and, when fulfilled, returns the updated row(s) or the number of rows affected.

    since

    1.1.0

    Parameters

    • connection: Connection

      An open connection to the akera.io application server.

    • query: IQueryUpdate

      The update query to execute.

    • Default value fetch: boolean = false

      If set to true the complete record will be returned if updated (field values might be updated by triggers).

    • Optional timeout: number

      The query execution timeout (milliseconds).

    Returns Promise<Record[] | Record | number>