Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueryDelete

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

  • QueryDelete

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.

    • Optional filter: Filter

      The filter condition for the table.

    Returns QueryDelete

Accessors

tables

  • The information on tables used on this query.

    Returns IQueryTable[]

Methods

filter

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

    Parameters

    • filter: Filter

      The filter condition to set on the table

    Returns QueryDelete

    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 QueryDelete

    Returns the current query instance (fluent interface).

on

  • on(parentField: string, childField?: string): QueryDelete
  • 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 QueryDelete

    Returns the current query instance (fluent interface).

Static delete

  • delete(connection: Connection, query: IQueryDelete, timeout?: number): Promise<number>
  • Asynchronously executes the delete query on a given connection and, when fulfilled, returns the number of affected (deleted) rows.

    Parameters

    • connection: Connection

      An open connection on which the query is to be executed.

    • query: IQueryDelete

      The query to execute.

    • Optional timeout: number

      The query execution timeout (milliseconds).

    Returns Promise<number>