this.table是一个工具类,您可以使用这个类对数据中心的数据表进行增删改查操作。
syntax
//您可以在页面、表单、流程各个嵌入脚本中,通过this.table()来返回table的对象,如下:
var table = new this.table( tablename )
parameters
-
tablename
string
数据表的id、名称或别名。
returns
-
object
table对象
source
methods
listrownext(id, count, successopt, failureopt, asyncopt) → {promise}
列示表中的行对象,下一页。
syntax
table.listrownext( id, count, success, failure, async )
//或
var promise = table.listrownext( id, count );
promise.then(function(json){
//json为返回的数据
})
parameters
-
id
string
当前页最后一条数据的id,如果是第一页使用"(0)"。
-
count
string
|number
下一页的行数
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
table.listrownext( "0", 20, function(data){
//data 形如
//{
// "type": "success",
// "data":[
// {
// "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
// "createtime": "2021-11-01 16:23:41", //数据创建时间
// "updatetime": "2021-11-01 16:23:41", //数据更新时间
// ... //定义的字段(列)和值
// }
// ],
// "message": "",
// "date": "2021-11-01 18:34:19",
// "spent": 13,
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
listrowprev(id, count, successopt, failureopt, asyncopt) → {promise}
列示表中的行对象,上一页。
syntax
table.listrowprev( id, count, success, failure, async )
//或
var promise = table.listrowprev( id, count );
promise.then(function(json){
//json为返回的数据
})
parameters
-
id
string
当前页第一条数据的id,如果是最后一页使用"(0)"。
-
count
string
|number
上一页的行数
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
table.listrowprev( "0", 20, function(data){
//data 形如
//{
// "type": "success",
// "data":[
// {
// "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
// "createtime": "2021-11-01 16:23:41", //数据创建时间
// "updatetime": "2021-11-01 16:23:41", //数据更新时间
// ... //定义的字段(列)和值
// }
// ],
// "message": "",
// "date": "2021-11-01 18:34:19",
// "spent": 13,
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
listrowselect(whereopt, orderbyopt, sizeopt, successopt, failureopt, asyncopt) → {promise}
根据条件获取表中的数据。
syntax
table.listrowselect( where, orderby, size, success, failure, async )
//或
var promise = table.listrowselect( where, orderby, size );
promise.then(function(json){
//json为返回的数据
})
parameters
-
where
string
查询条件,格式为jpql语法,o.name='zhangsan',允许为空。
-
orderby
string
排序条件,格式为:o.updatetime desc,允许为空
-
size
string
|number
返回结果集数量,允许为空。
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
//查询字段name等于zhangsan的数据,结果按updatetime倒序
table.listrowselect( "o.name='zhangsan'", "o.updatetime desc", 20, function(data){
//data 形如
//{
// "type": "success",
// "data":[
// {
// "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
// "createtime": "2021-11-01 16:23:41", //数据创建时间
// "updatetime": "2021-11-01 16:23:41", //数据更新时间
// ... //定义的字段(列)和值
// }
// ],
// "message": "",
// "date": "2021-11-01 18:34:19",
// "spent": 13,
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
rowcountwhere(where, successopt, failureopt, asyncopt) → {promise}
通过where 统计数量。
syntax
table.rowcountwhere( where, success, failure, async )
//或
var promise = table.rowcountwhere( where );
promise.then(function(json){
//json为返回的数据
})
parameters
-
where
string
查询条件,格式为jpql语法,o.name='zhangsan'。
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
//查询字段name等于zhangsan的数据,结果按updatetime倒序
table.rowcountwhere( "o.name='zhangsan", function(data){
//data 形如
//{
// "type": "success",
// "data": {
// "value": 5 //符合条件数据的总条数
// },
// "message": "",
// "date": "2021-11-01 18:32:27"
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
deleterow(id, successopt, failureopt, asyncopt) → {promise}
删除数据表中指定id的记录。
syntax
table.deleterow( id, success, failure, async )
//或
var promise = table.deleterow( id );
promise.then(function(json){
//json为返回的数据
})
parameters
-
id
string
需要删除记录的id。
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
table.deleterow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){
//data 形如
//{
// "type": "success",
// "data": {
// "value": true //true表示删除成功,false表示无此数据
// },
// "message": "",
// "date": "2021-11-01 18:32:27"
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
deleteallrow(successopt, failureopt, asyncopt) → {promise}
删除指定表中所有行的数据。
syntax
table.deleteallrow( success, failure, async )
//或
var promise = table.deleteallrow();
promise.then(function(json){
//json为返回的数据
})
parameters
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
table.deleteallrow( function(data){
//data 形如
//{
// "type": "success",
// "data": {
// "value": 1 //表示删除的条数,0表示无数据
// },
// "message": "",
// "date": "2021-11-01 18:32:27"
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
getrow(需要获取记录的id。, successopt, failureopt, asyncopt) → {promise}
获取数据表中指定id的记录。
syntax
table.getrow( id, success, failure, async )
//或
var promise = table.getrow( id );
promise.then(function(json){
//json为返回的数据
})
parameters
-
需要获取记录的id。
id
-
success
function
调用成功时的回调函数。
-
failure
function
调用错误时的回调函数。
-
async
boolean
是否异步调用,默认为true。
returns
-
promise
返回promise
example
var table = new this.table("table1");
table.getrow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){
//data 形如
//{
// "type": "success",
// "data":{
// "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
// "createtime": "2021-11-01 16:23:41", //数据创建时间
// "updatetime": "2021-11-01 16:23:41", //数据更新时间
// ... //定义的字段(列)和值
// },
// "message": "",
// "date": "2021-11-01 18:34:19",
// "spent": 13,
//}
}, function(xhr){
//xhr 为 xmlhttprequest
});
source
insertrow(data, successopt, failureopt, asyncopt) → {promise}
往数据表中批量插入数据。
syntax
table.insertrow( data, success, failure, async )
//或
var promise = table.insertrow( data );
promise.then(function(json){
//json为返回的数据
})
parameters
-
data
array.