【TcaplusDB知识库】RESTfulAPI. for List表-[PB] [PB] ListBatchGetRecord介绍
简介
在List PB表中批量查询指定Key下的记录。
-
Index: 指定要返回记录的下标。
POST http://{Tcaplus_REST_URL}
请求语法
Http请求
#腾讯云控制台 RESTful Endpoint, ip:80, 端口默认80
http://172.17.0.22
#TcaplusDB本地docker版 RESTful Endpoint, ip:31001, 端口默认31001
http://9.135.8.93:31001
Http头
x-tcaplus-target:Tcaplus.ListBatchGetRecords
x-tcaplus-app-id:{string}
x-tcaplus-zone-id:{string}
x-tcaplus-protocol-version:{string}
x-tcaplus-table-name:{string}
x-tcaplus-pwd-md5:{string}
x-tcaplus-result-flag:result_flag
x-tcaplus-version:{string}
x-tcaplus-data-version-check:{string}
x-tcaplus-idl-type:protobuf
参数说明:
| 名称 | 是否必填 | 限制条件 | 说明 |
|---|---|---|---|
| x-tcaplus-target | 是 | 无 | Tcaplus.ListBatchGetRecords |
| x-tcaplus-version | 是 | 无 | Tcaplus3.50.0 |
| x-tcaplus-app-id | 是 | 无 | 对应业务id编号(aka,集群接入id) |
| x-tcaplus-zone-id | 是 | 无 | 对应zone编号(aka,表格组id) |
| x-tcaplus-protocol-version | 是 | 无 | 对应protocol版本号,默认2.0 |
| x-tcaplus-table-name | 是 | 无 | 对应表名 |
| x-tcaplus-pwd-md5 | 是 | 无 | 业务密码(aka,集群访问密码),传入计算后的md5值 |
| x-tcaplus-idl-type | 是 | 无 | protobuf |
| x-tcaplus-result-flag | 否 | 无 | 0:操作成功后不返回数据1:操作成功后返回和请求一致的数据2:操作成功后返回本次update操作后的数据3:操作成功后返回tcapsvr端操作前的数据 |
| x-tcaplus-data-version-check | 否 | 1:检测记录版本号,只有当该版本号与服务器端的版本号相同时,该版本号才会自增2:不检测记录版本号,强制把客户端的记录版本号写入到服务器中3:不检测记录版本号,将服务器端的版本号自增 | |
| x-tcaplus-data-version | 否 | 具体的version值 |
示例:
x-tcaplus-target:Tcaplus.ListBatchGetRecords
x-tcaplus-app-id:3
x-tcaplus-zone-id:1
x-tcaplus-protocol-version:2.0
x-tcaplus-table-name:tb_online_list
x-tcaplus-pwd-md5:4e81984efccfb4982333aeb1ff7968d5
x-tcaplus-result-flag:2
x-tcaplus-version:Tcaplus3.50.0
x-tcaplus-data-version-check: 3
x-tcaplus-idl-type:protobuf
Data
使用json格式表示记录相关信息。指定要获取的Key,及对应的多条记录的下标,
-
Indexes: 必须,数组,指定要获取记录的下标,支持指定多个
-
Record: 指定要获取记录的主键
{
"Indexes": [0,1],
"Record": {
"openid": 1,
"timekey": "1",
"tconndid": 1
}
}
完整请求示例
curl -i -XPOST -H 'x-tcaplus-target: Tcaplus.ListBatchGetRecords' -H 'x-tcaplus-app-id: 70' -H 'x-tcaplus-zone-id: 1' -H 'x-tcaplus-protocol-version: 2.0' -H 'x-tcaplus-table-name: tb_online_list' -H 'x-tcaplus-pwd-md5: 0972ad76decf4d11a69e2e0d9af335da' -H 'x-tcaplus-result-flag: 1' -H 'x-tcaplus-version: Tcaplus3.50.0' -H 'x-tcaplus-data-version-check: 1' -H 'x-tcaplus-idl-type: protobuf' http://172.17.32.17 -d '{
"Indexes": [4,5],
"Record": {
"openid": 1,
"timekey": "1",
"tconndid": 1
}
}'
返回语法
{
“ErrorCode”:errCode,
“ErrorMsg”:errMsg,
“SucceedRecords”:RecordJsonObjs,
“ReturnValues”:RetVal,
“SucceedNum”:int,
“SucceedRecords”:RecordJsonObjs,
“FailedRecords”:RecordJsonObjs,
“FailedNum”:int
}
返回参数说明
| 参数名 | 说明 |
|---|---|
| ErrorCode | 返回码 |
| ErrorMsg | 返回信息 |
| RecordVersion | 当前记录的版本号 |
| SucceedRecords | json格式,成功的记录返回数据,详见文中Data部分 |
| SucceedNum | 成功的记录数 |
| FailedRecords | json格式,失败的记录返回数据,详见文中Data部分 |
| FailedNum | 失败的记录数 |
返回示例
成功示例
{
"ErrorCode": 0,
"ErrorMsg": "Succeed",
"SucceedRecords": [{
"RecordVersion": 28,
"Index": 4,
"Record": {
"openid": 1,
"tconndid": 1,
"timekey": "1",
"gamesvrid": "1",
"logintime": 1,
"lockid": [],
"pay": {
"total_money": 1,
"pay_times": 1
}
}
}, {
"RecordVersion": 28,
"Index": 5,
"Record": {
"openid": 1,
"tconndid": 1,
"timekey": "1",
"gamesvrid": "2",
"logintime": 2,
"lockid": [],
"pay": {
"total_money": 2,
"pay_times": 2
}
}
}],
"SucceedNum": 2
}
失败示例
{
"ErrorCode": -1299,
"ErrorMsg": "api_field_not_exist_error",
"SucceedRecords": [{
"RecordVersion": 28,
"Index": 4,
"Record": {
"openid": 1,
"tconndid": 1,
"timekey": "1",
"gamesvrid": "1",
"logintime": 1,
"lockid": [],
"pay": {
"total_money": 1,
"pay_times": 1
}
}
}],
"SucceedNum": 1,
"FailedRecords": [{
"Index": 0
}, {
"Index": 3
}],
"FailedNum": 2
}
