Help Center/ Huawei Cloud Astro Zero/ API Reference/ APIs/ Data Modules/ Querying the Number of Object Records by Condition
Updated on 2025-05-13 GMT+08:00

Querying the Number of Object Records by Condition

Function

This API is used to query the number of object records by condition.

URI

POST Huawei Cloud Astro Zero domain name/u-route/baas/data/v1.0/count/{objectName}?base=X

Table 1 URI parameters

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

base

No

String

Explanation

Query parameter, which is used to distinguish the data passed by objectName.

Constraints

None

Value

The options are as follows:

  • I: ID of the corresponding object.
  • N: An object name is transferred.

Default value

None

Request Parameters

Table 2 Request parameter

Parameter

Mandatory

Type

Description

condition

Yes

Object

Explanation

Query conditions. If this parameter is left unspecified, all object data is queried. This parameter contains the following elements:

  • conjunction: number of conditions to meet.
    • AND: All conditions must be met.
    • OR: At least one condition must be met.
  • conditions: array of conditions. If this parameter is left unspecified, all object data is queried. If this parameter is specified, each element contains the following fields:
    • field: field name.
    • operator: operator, which can be: eq indicates equal to, ne indicates not equal to, gt indicates greater than, lt indicates less than, ge indicates greater than or equal to, and le indicates less than or equal to.
    • value: comparison value.
  • relation: The array contains parents (upward query) and children (downward query).

    The parents field contains the condition array and relatedField (name of the associated field). The children field contains the condition array and relationName (name of the associated field).

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

Value

None

Example Request

To query the number of records where name is lisi in the TestProject__testForObject1__CST object, send the following request:
POST https://Huawei Cloud Astro Zero domain name/u-route/baas/data/v1.0/count/TestProject__testForObject1__CST 
  
 {
    "condition": {
        "conjunction": "AND",
        "conditions": [
            {
                "field": "NAME",
                "operator": "eq",
                "value": "lisi"
            }
        ]
    }
}

Example Response

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

Status Code

See Status Codes.

Error Code

See Error Codes.