Declaration
ok, value info = UpdateData(string key, function updateFunction)
Parameters
Parameter Name | Parameter Description | |
---|---|---|
key | string | Key of the data to be updated. Only numeric type is supported. |
updateFunction | function | Function used for updating the data. |
Return Values
Response Name | Response Type | Description |
---|---|---|
ok | int | If the value is 0, the value assignment operation is successful. Otherwise, the operation fails. |
value | double or string | If the operation is successful, the updated value is returned. Otherwise, an error message is returned. |
info | ParaOrderedDataInfo | If the operation is successful, the detailed information (such as version and metadata) is returned. |
Description
Updates data with a function.
Updates the data corresponding to a key through a callback function. The callback function gets the current value and returns the new value based on the defined logic. The callback function cannot be paused once executed.
Callback Function Declaration
newValue = updateFunction(double currentValue, ParaOrderedDataInfo info)
Callback Function Parameters
Parameter Name | Response Type | Parameter Description |
---|---|---|
currentValue | double | Current value. |
info | ParaOrderedDataInfo | Additional information about the current value. |
Callback Function Response Declaration
Response Name | Response Type | Description |
---|---|---|
newValue | double | Expected new value. |