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 condition 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.

For the modification request, it can also set update operations through the operation interface. Currently, it refers to the insertion (PUSH), deletion (POP), and modification (SET) of an array.

For example:

int TcaplusCoroutinePbApi::FieldSet(
    const std::set<std::string> &dottedpaths, 
    google::protobuf::Message *msg,
    const std::string &operation,
    const std::string &condition);

Examples

user u;
// Set primary key
u.set_id(1);
u.set_name("a");

// Set the step size of increase
u.set_rank(1);
// When the rank reaches the upper limit of 100, it will not be increased; otherwise, it will be increased by one.
std::set<std::string> dottedpaths;
dottedpaths.insert("rank");
ret = api.FieldInc(dottedpaths, &u, "", "rank < 100");

The above condition and operation settings are SQL like text, see Detailed Syntax Description.

2. Which Interfaces Support Condition Update?

In the SDK with version 3.55.0 or higher, the supported commands are

  • Get
  • Del
  • Set
  • Update
  • FieldGet
  • FieldInc
  • FieldSet
  • IndexGetRequest
  • Query, GET of an array, that is, query and return part array elements in a subscript range. It is more recommended to use FieldGet to query and return array elements in a subscript range
  • UpdateItem: PUSH, SET and POP operations of an array
  • Traverse
  • ListGet
  • ListGetAll
  • ListDel
  • ListBatchDel
  • ListReplace
  • ListTraverse
  • ListQuery
  • ListUpdateItem

Part requests and batch operations can only be supported if the version is greater than or equal to 3.64.0, including

  • IndexDeleteRequest
  • BatchGet
  • BatchUpdate
  • BatchDelete
  • BatchSet
  • BatchFieldGetRequest

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 condition and operation is 1023.

results matching ""

    No results matching ""