-
Notifications
You must be signed in to change notification settings - Fork 0
SimpleCURD SDK
// 初始化
var client = new DBCURD("test_curd");
// 获取信息
client.info(console.log);
// 获取列表
client.list({ page: 2 }, console.log)
// 创建数据
client.create({
username: "Yourtion",
}, console.log)
// 更新数据
client.update(23248, { username: "Yourtion2" }, console.log)
// 获取单条记录
client.get(23248, console.log)
// 获取记录和排名
client.rank(23248, "id", console.log)
// 数据记录自增
client.incr(23248, "weight", console.log)
-
DBCURD
- new client(table, option)
- .info(cb)
- .list(listInfo, cb)
- .page(pageInfo, cb)
- ._create(data, update, info, cb) ℗
- .create(data, cb)
- ._update(field, value, data, cb) ℗
- .update(key, data, cb)
- ._get(field, data, rankKey, count, cb) ℗
- .rank(value, rankKey, cb)
- .get(value, cb)
- ._incr(primary, field, count, cb) ℗
- .incr(primary, field, cb)
funcCallback : function
Param | Type | Description |
---|---|---|
err | Error |
null |
data | Object |
undefined |
Param | Type | Description |
---|---|---|
table | String |
表名 |
option | Object |
初始化参数 |
option.field | String |
默认主键(id) |
option.host | String |
主机(100jc) |
Example js var client = new DBCURD("test_curd", { field: "openid" });
获取表信息
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
cb | funcCallback |
回调 |
Example js client.info(console.log);
获取列表
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
listInfo | Object |
分页参数 |
listInfo.limit | Number |
获取数据数量 |
listInfo.offset | Number |
跳过条数 |
listInfo.fields | Boolean |
所选字段 |
listInfo.addtion | Object |
更多筛选字段 |
cb | funcCallback |
回调 |
Example js client.list({ limit: 2, offset: 2 }, console.log)
获取列表
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
pageInfo | Object |
分页参数 |
pageInfo.page | Number |
第n页 |
pageInfo.pageCount | Number |
每页数量 |
pageInfo.order | String |
排序字段 |
pageInfo.asc | Boolean |
是否升序 |
pageInfo.fields | Boolean |
所选字段 |
pageInfo.addtion | Object |
更多筛选字段 |
cb | funcCallback |
回调 |
Example js client.list({ page: 2 }, console.log)
创建记录
Kind: instance method of DBCURD
Access: private
Param | Type | Description |
---|---|---|
data | Object |
收集的数据 |
update | Boolean |
插入冲突是否更新数据 |
info | Boolean |
是否需要数据详情 |
cb | funcCallback |
回调 |
Example js client.create({ username: "Yourtion" }, console.log)
创建记录
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
data | Object |
收集的数据 |
cb | funcCallback |
回调 |
更新数据
Kind: instance method of DBCURD
Access: private
Param | Type | Description |
---|---|---|
field | String |
唯一键名 |
value | String |
唯一键的值 |
data | Object |
更新的数据 |
cb | funcCallback |
回调 |
更新数据
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
key | String |
主键的值 |
data | Object |
更新的数据 |
cb | funcCallback |
回调 |
Example js client.update(23248, { username: "Yourtion2" }, console.log)
获取单条数据和排名
Kind: instance method of DBCURD
Access: private
Param | Type | Description |
---|---|---|
field | String |
唯一键名 |
data | String |
查询键的值 |
rankKey | String |
排名的键 |
count | Boolean |
计算总数 |
cb | funcCallback |
回调 |
获取单条数据和排名
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
value | String |
查询键的值 |
rankKey | String |
排名的键 |
cb | funcCallback |
回调 |
Example js client.rank(23248, "id", console.log)
获取单条数据
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
value | String |
查询键的值 |
cb | funcCallback |
回调 |
Example js client.get(23248, console.log)
数据条目自增
Kind: instance method of DBCURD
Access: private
Param | Type | Description |
---|---|---|
primary | String |
主键的值 |
field | String |
需要自增的字段名 |
count | Number |
需要自增数量(默认1) |
cb | funcCallback |
回调 |
数据条目自增 1
Kind: instance method of DBCURD
Param | Type | Description |
---|---|---|
primary | String |
主键的值 |
field | String |
需要自增的字段名 |
cb | funcCallback |
回调 |
Example js client.incr(23248, "weight", console.log)