-
Notifications
You must be signed in to change notification settings - Fork 0
JSQL update
update(tableName[, options])
JSQL query used to update a record in the database.
The name of the table to update. update will throw an error if tableName is an empty string or ends with a period.
If the name contains a space, everything after the last space will be ignored.
If the name contains a period, everything before the last period (which is also before the last space) will be used to choose the schema to store the table in. If the name does not contain a period, the default schema will be used.
The name "triggers" is reserved, and may not be used for the table.
See options for additional information.
Options for modifying the behavior of the update query.
| Property | Default | Explanation |
|---|---|---|
| useTransaction | null |
If set to a Transaction object, executing the query will add the query to the transaction's queue instead of actually executing it.
|
The update function returns a Update object, which is a subclass of cls.QueryBuilder. This object has the following functions you can use to build your query:
Sets a single field of the records to be updated, and optionally the value for that field.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| name | String | No | Must be non-empty |
| value | varies | Yes | The value will be fed into the type handler for the given field before being stored in the database. |
Sets a single value of the records to be updated.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| value | varies | No | The value will be fed into the type handler for the given field before being stored in the database. |
Sets multiple fields of the records to be updated, and optionally the values for those fields.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| names | Array of Strings | No | Must have at least one element, and all elements must be non-empty. |
| values | Array | Yes |
Must have the same number of elements as names. Each value will be fed into the type handler for the given field before being stored in the database.
|
Sets multiple fields of the records to be updated.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| names | String args | No | Must have at least one argument, and all arguments must be non-empty. |
Sets multiple fields of the records to be updated as well as their values.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| fields | Object | No | Must have at least one key. Each key must be a non-empty string. Each value will be fed into the type handler for the given field before being stored in the database. |
Sets multiple values of the records to be updated.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| values | Array or args | No | Must have at least one element or at least one argument. Each value will be fed into the type handler for the given field before being stored in the database. |
Creates a condition to limit what records are updated. See expr for more information.
| Parameter | Type | Optional | Remarks |
|---|---|---|---|
| expr | varies args | No |
At least one argument must be supplied. For each argument:
|
Performs the update operation.
options.useTransaction can override the same option specified in update and cls.DefaultOptions.
If the number of fields and the number of values specified by various calls to field, value, fields, and values are not the same, this function will throw an error.
This function will return the number of records updated.
- options
- examples
- known bugs/missing features
- Table Functions
- C.R.U.D. Functions
- Meta Functions