函数:cloud_db_update 修改数据

方法名称:修改数据

方法功能:修改指定数据

调用方法

ok,err = ts_enterprise_lib:cloud_db_update(table_id,where,data,timeout_seconds);

参数 类型 必填 说明 默认值
table_id string 云数据库表 ID,
点击云数据库中表后方的复制 ID 按钮即可复制粘贴
-
where table 修改条件,格式为键值对,
对应列名和数据可写多个条件
条件更多写法参考查询数据
-
data table 修改数据,格式为键值对,对应列名和数据 -
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长 5
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
err string 当 ok 等于 true,返回用户查询的实际结果
当 ok 等于 false,返回错误原因

函数用例

--修改单条数据
--企业版库为企业版专用库请勿在除企业版外的产品使用,此库已内置,无需下载
--如果提示没有 ts_enterprise_lib 库请重启企业版客户端服务再试
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
local table_id = '58b7968986d4e24f4a0cf4e5'         --表 ID
local where = {a=2}                                 --条件
local data = {a=5}
local timeout_seconds = 5                           --超时时间
local ok,err = ts_enterprise_lib:cloud_db_update(table_id,where,data,timeout_seconds)
if ok then
    dialog("成功")
else
    dialog(err)
end
--修改多条数据
--引入中控库
--企业版库为企业版专用库请勿在除企业版外的产品使用,此库已内置,无需下载
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
local table_id = '5da03ff47ed2f8003a83e7fa'         --表 ID
local where = { }
local or2 = {}
or2[1] = {a = "9"}
or2[2] = {a = "8"}
where['or'] = or2                                   --条件
local data= {a="10",b="11"}  
local timeout_seconds = 10                          --超时时间
local ok,err = ts_enterprise_lib:cloud_db_update(table_id,where,data,timeout_seconds)
if ok then
    dialog("成功")
else
    dialog(err)
end

注意事项

  • 如果 err 返回 timeout 请增加 timeout_seconds 的时间,非 mSleep 时间。
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""