跳到主要内容

setByUK 更新单条记录

setByUK 根据唯一键更新单条记录。

Luwak >= 3.0.0, asm.so >= 0.1.4

API

公共参数 metas 对象

名称类型描述
tokenstring访问令牌,当需要授权才能访问时为必填
signaturestring签名
appKeystring当需要签名时为必填
timestampstring, number时间戳,当校验时间误差范围时为必填

请求参数

名称类型描述
methodstringAPI 名称
paramsarrayAPI 参数

method 命名规范是 $entity.setByUK

params 参数是一个数组,包含一个唯一键对象和一个数据对象。

响应结果

返回受影响的行数

示例

场景描述

更新品牌表中唯一键 id 为 1 的记录。

请求

{
"jsonrpc": "2.0",
"method": "smartPanda.mdh.brand.setByUK",
"params": [
{
"id": 1
},
{
"name": "Luwak"
}
],
"metas": {
"token": "44ea16b7-3aa1-41a5-81da-8ee9d2b840c2",
"signature": "7041842a5430cfbf197039ae8f224fea",
"appKey": "NSEA4ETIpBlyB2l9",
"timestamp": 1740640810940
},
"id": "ed6c1772-0dc9-439a-a15a-5d6a76944268"
}

响应

{
"jsonrpc": "2.0",
"result": 1,
"id": "ed6c1772-0dc9-439a-a15a-5d6a76944268"
}

实体定义

smart_panda 库中 brand 表的定义如下

CREATE TABLE `brand`
(
`id` int AUTO_INCREMENT,
`name` varchar(20),
PRIMARY KEY (`id`)
);

entity 名称是 smartPanda.mdh.brand

实际执行的 SQL

Prepare   UPDATE smart_panda.brand SET name = ? WHERE id = ?
Execute UPDATE smart_panda.brand SET name = 'Luwak' WHERE id = 1