Conditional Filter and Update
Conditional update includes two parts: conditional filter and update. The latter currently refers to updating arrays.
1. Instructions
For addition, deletion, modification and query, filter conditions can be set through the SetCondition interface. Only when the conditions are met, the query data will be returned or the update operation will be performed. Otherwise, error codes COMMON_ERR_CONDITION_NOT_MATCHED will be returned.
/**
@brief: set the filter condition
@param [IN] filter: filter condition, such as: fieldValue > 4
@retval int: error code
**/
func (r *Record) SetCondition(filter string) int { ... }
For the modification request, in addition to SetData to set the data, it can also set update operations through the SetOperation interface. Currently, it refers to the insertion (PUSH), deletion (POP), and modification (SET) of arrays.
/**
@brief: set the additional operation
@param [IN] operation: additional operation: PUSH gameids #[-1][$=123]
@param [IN] operateOption: additional operation type 0|1
@retval int: error code
**/
func (r *Record) SetOperation(operation string, operateOption int32) int { ... }
The above SetCondition and SetOperation settings are SQL like text, see Detailed Syntax Description.
2. Which Requests Support Conditional Updates?
SDK versions greater than or equal to 3.55.0 support the following
- TcaplusApiGetReq
- TcaplusApiDeleteReq
- TcaplusApiReplaceReq
- TcaplusApiUpdateReq
- TcaplusApiGetByPartkeyReq
- TcaplusApiPBFieldGetReq
- TcaplusApiPBFieldUpdateReq
- TcaplusApiPBFieldIncreaseReq
- TcaplusApiListGetReq
- TcaplusApiListGetAllReq
- TcaplusApiListDeleteBatchReq
- TcaplusApiListDeleteReq
- TcaplusApiListReplaceReq
- TcaplusApiTableTraverseReq
- TcaplusApiListTableTraverseReq
Part requests and batch operations require 3.64.0 or greater to be supported, including
- TcaplusApiIncreaseReq
- TcaplusApiUpdateByPartkeyReq
- TcaplusApiDeleteByPartkeyReq
- TcaplusApiBatchGetReq
- TcaplusApiBatchDeleteReq
- TcaplusApiBatchUpdateReq
- TcaplusApiBatchReplaceReq
Fieldget and FieldUpdate can implement Schema-free Like Function with the support of conditional filtering and updating.
For more functional support of conditional filtering and updating, please contact Tcaplus.
3. Notations
- The maximum text length of parameters
filterandoperationis 1023.