Update
Executes a query to update data in a table.
Possible Crash
Methods
data()
→ (object = Object) → this
Updates all matching rows with the provided data.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | Object | An object where keys represent column names and values represent the new data. |
Returns
→ this
selectDatabase()
→ (database = String) → this
Selects a different database for the query.
Parameters
| Parameter | Type | Description |
|---|---|---|
database | String | The name of the database to use for the update. |
Returns
→ this
force()
→ () → this
Allows updates on all rows in the table.
Returns
→ this
where()
→ (string = String, values = Array<any>) → this
Adds a WHERE clause to filter the update query.
- Use
?as placeholders in the condition string to prevent SQL injection.
Parameters
| Parameter | Type | Description |
|---|---|---|
string | String | The WHERE clause with ? placeholders. |
values | Array<any> | An arrray of values replacing the placeholders in left-to-right order. |
Returns
→ this
execute()
async → () → OkPacket
Executes the prepared update query.
Returns
→ OkPacket