Delete
Performs a query to delete rows from a table.
Possible crash
Methods
selectDatabase()
→ (database = String) → this
Sets the database for this query.
Parameters
| Parameter | Type | Description |
|---|---|---|
database | String | The database name to select. |
Returns
→ this
where()
→ (string = String, values = Array<any>) → this
Addsa WHERE clause to the delete query.
- Use placeholders (
?) in the condition string and provide values in thevaluesarray to prevent SQL injection. - If using joins, specify the table and column together:
"table.column".
Parameters
| Parameter | Type | Description |
|---|---|---|
string | String | SQL WHERE condition with ? placeholders. |
values | Array<any> | Values replacing ?, in left-to-right order. |
Example Usage
.delete().where("id = ?", [5])
Returns
→ this
force()
→ () → this
Enables deletion of all rows, overriding the safeguard in execute().
Returns
→ this
execute()
async → () → OkPacket
Executes the prepared DELETE query.
Returns
→ OkPacket