函数:batch_data 批量获取数据

方法名称:批量获取数据

方法功能:从数据中心单次获取多条数据

调用方法

ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","batch_data",category,count);

参数 类型 必填 说明
category string 数据中心分类名
count number 获取数据数量
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等于 true,返回数据获取状态
当 ok 等于 false,返回错误原因
ret2 string/table 当 ret1 等于 true,返回 table 格式的数据
当 ret1 等于 false,返回失败原因

函数用例

--批量取数据
--企业版库为企业版专用库请勿在除企业版外的产品使用,此库已内置,无需下载
--如果提示没有 ts_enterprise_lib 库请重启企业版客户端服务再试
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
local ts = require("ts")--使用扩展库前必须插入这一句
local json = ts.json--使用 JSON 模块前必须插入这一句
local category = "分类名" --数据中心分类名
local count = 10 --取数据数量
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","batch_data",category,count)
if ok then
    if ret1 then
        --返回一个数组 table
        nLog("batch_data 成功:"..json.encode(ret2))
    else
        nLog("batch_data 失败:"..ret2)
    end
else
    nLog("batch_data 失败:"..ret1)
end
mSleep(5000)

注意事项

  • 错误返回 timeout 请在获取数据前增加代码 ts_enterprise_lib.timeout = 20,如果仍返回 timeout 请修改为 20 以上的数字
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""