Skip to main content

Delete

Performs a query to delete rows from a table.

Possible crash

To prevent accidental deletion of all rows, this will throw an error on execute() if no where() was defined.

To enable the deletion of all rows use force().

Methods

selectDatabase()

→ (database = String) → this

Selects a different database for this query.

Parameters

ParameterTypeDescription
databaseStringName of the database to select

Returns

this


where()

→ (string = String, values = Array<any>) → this

Adds a where-clause to the query

  • Values should be set as ? in the string and given in left-to-right order via the 'values'-array to minimize the risk of sql-injection
  • If you are using joins, specify the table and column together: table.column

Parameters

ParameterTypeDescription
stringStringThe where-clause as a string with ? representing each values.
valuesArray<any>Array containing values replacing the ? in the string (from left to right)

Returns

this


force()

→ () → this

Enables deletion of all rows.

Returns

this


execute()

async → () → any

Executes the prepared query.

Returns

any - Query result