Updated on 2025-08-14 GMT+08:00

Updating Data by Condition

Function

This API is used to update data by condition. It is a synchronous API. (Invocation result is returned only after the function execution is complete.)

Before calling this API, you must create an object and data records.

URI

PUT Huawei Cloud Astro Zero domain name/u-route/baas/data/v1.0/bobject/{objectName}

Table 1 URI parameter

Parameter

Mandatory

Type

Description

objectName

Yes

String

Explanation

Data object name. For details, see Logging In to the Application Designer. You can access the application designer and choose Data > Object to view data object names.

Constraints

None

Value:

1–80 characters

Default value

None

Request Parameters

Table 2 Request parameters

Parameter

Mandatory

Type

Description

setValue

Yes

Object

Explanation

Modifies the fields and values of an object. You can do as follows to view the fields and values of an object:

  1. Access the application designer by referring to Logging In to the Application Designer.
  2. Choose Data > Object, click over the object, and choose Details.
  3. On the Fields tab page of the object details page, view the fields contained in the object and their values.

Constraints

None

condition

Yes

Object

Explanation

Condition for updating a record, which is similar to the where condition in SQL statements.

Constraints

None

Response Parameters

Table 3 Response parameters

Parameter

Type

Description

resCode

String

Explanation

Return code.

Value

If the request is successful, 0 is returned. For details about other error codes, see Error Codes.

resMsg

String

Explanation

Message returned.

Value

If the request is successful, "Success" is returned. In other cases, an error message is returned.

result

Number

Explanation

Number of updated records. This parameter is carried when the request is successful.

Value

None

Example Request

To select records where name is newName in the TestProject__testForObject__CST object and update the name value to name3, send the following request:
PUT https://Huawei Cloud Astro Zero domain name/u-route/baas/data/v1.0/bobject/TestProject__testForObject__CST
 
{
    "setValue": {
        "name": "name3"
    },
    "condition": {
        "conjunction": "AND",
        "conditions": [
            {
                "field": "name",
                "operator": "eq",
                "value": "newName"
            }
        ]
    }
}

Example Response

{
    "resCode": "0",
    "resMsg": "Success",
    "result": 1
}

Status Code

See Status Codes.

Error Code

See Error Codes.