Declaration
ok, ret_value, info = UpdateData(key, updateFunction)
Parameters
Parameter Name | Type | Description |
---|---|---|
key | string | Key of the data to be updated. |
updateFunction | updateFunction(currentValue, ParaDataInfo info) | Function used for updating the data. |
Return Values
Response Name | Type | Description |
---|---|---|
ok | int | If the value is 0, the operation is successful. The subsequent fields are the updated value and detailed information. |
value | number, boolean, string, | If the operation is successful, the updated value is returned. Otherwise, an error message is returned. |
info | ParaDataInfo | If the operation is successful, the detailed information (such as version and metadata) is returned. |
Description
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 Signature
newValue, newOptions updateFunction(currentValue, info)
Parameters
Parameter Name | Type | Description |
---|---|---|
currentValue | number, boolean, string, | Current value. |
info | ParaDataInfo | Additional information about the current value. |
newValue | number, boolean, string, | Expected new value. |
newOptions | ParaDataSetOptions | Metadata expected to be stored. |
Description
Updates data with a function.