orm表

ormtable

function M:new(tab_name)

描述

新建表对象
参数

  • tab_name string 作用与数据库的表名

返回值

  • table obj

function M:___FIELD_TYPE(field_name)

描述

设置字段 FIELD_TYPE对应字段类型 有 int8|int16|int32|int64|uint8|uint16|uint32|string32|string64|string128|string256|string512|string1024|string2048|string4096|string8192|text|blob|table
参数

  • field_name string 字段名

返回值

  • table obj

function M:set_keys(…)

描述

设置主键
参数

  • … string 字段名列表 填入遵从最左前缀原则

返回值

  • table obj

function M:set_cache(expire, inval, cache_limit)

描述

设置缓存时间
参数

  • expire number 过期时间 100表示1秒 get_*相关接口会重置对应被获取的entry的过期时间
  • inval number 被修改后的保存检查间隔 调用了entry:set
  • cache_limit number 缓存总量限制,超出会优先释放快到期的缓存

返回值

  • table obj

function M:builder(adapterinterface)

描述

构建表
参数

  • adapterinterface number 数据库适配接口

返回值

  • table obj

function M:create_entry(entry_data_list)

描述

批量创建新数据
参数

  • entry_data_list table 数据列表

返回值

  • table obj

function M:create_one_entry(entry_data)

描述

创建一条数据
参数

  • entry_data table 一条数据表

返回值

  • table obj

function M:get_entry(…)

描述

查询多条数据
参数

  • … string[] 最左前缀的 key 列表

返回值

  • table obj

function M:get_one_entry(…)

描述

查询一条数据
参数

  • … string[] 最左前缀的 key 列表

返回值

  • table obj(ormentry)

function M:save_entry(entry_list)

描述

立即保存数据
参数

  • entry_list table ormentry对象列表

返回值

  • table 保存结果索引对应值 成功true失败false

function M:save_one_entry(entry)

描述

立即保存一条数据
参数

  • entry table ormentry对象

返回值

  • boolean 成功true失败false

function M:delete_entry(…)

描述

删除数据
参数

  • … string[] 最左前缀的 key 列表

返回值

  • boolean 成功true失败false

function M:get_all_entry()

描述

查询所有数据
参数

返回值

  • table obj

function M:delete_all_entry()

描述

删除所有数据
参数

返回值

  • boolean 成功true失败false

function M:save_change_now()

描述

立即保存所有修改,直到成功为止
参数

返回值

function M:get_entry_by_data(entry_data)

描述

通过数据获得entry
参数

  • entry_data table 数据表

返回值

  • table obj(ormentry)

function M:is_inval_save()

描述

是否启用了间隔保存
参数

返回值

  • boolean

function M:get_entry_by_limit(cursor, limit, sort, …)

描述

分页查询
参数

  • cursor number|string 游标
  • limit number 数量限制
  • sort number 1升序 -1降序
  • … string[] 最左前缀主键列表

返回值

  • table obj

function M:get_entry_by_in(in_values, …)

描述

IN 查询
参数

  • in_values table in对应的值列表 select * from xxx where key1 = xxx and key2 = xxx and key3 in (xxx,xxx,xxx)
  • … string[] 最左前缀主键列表 无需填入in_values的key

返回值

  • table obj

function M:delete_entry_by_range(left, right, …)

描述

范围删除 包含left right 可以有三种操作方式 [left, right] 范围删除 >= left <= right [left, nil] 删除 >= left [nil, right] 删除 <= right
参数

  • left string|number 左值
  • right string|number 右值
  • … string[] 最左前缀主键列表 无需填入left right值 对应的key

返回值

  • boolean

function M:delete_entry_by_in(in_values, …)

描述

IN 删除
参数

  • in_values table in对应的值列表 delete from xxx where key1 = xxx and key2 = xxx and key3 in (xxx,xxx,xxx)
  • … string[] 最左前缀主键列表 无需填入in_values的key

返回值

  • boolean

orm表
https://huahua132.github.io/2024/06/29/skynet_fly_api_word/db/orm/ormtable/
作者
huahua132
发布于
2024年6月29日
许可协议