Members
Methods
delete() → {Array}
删除数据
Returns:
- Type:
-
Array
json数组
用法:delete()
注意 如delete方法前方没有where进行判断,就会清楚json里面的所有数据;
如有就会进行删除json中出现那个值
deleteKey(key) → {this}
删除键名
Parameters:
Name | Type | Description |
---|---|---|
key |
String
|
要删除的键名 |
Returns:
- Type:
-
this
this
用法:deleteKey('age')
domExport(filename)
dom导出
Parameters:
Name | Type | Default | Description |
---|---|---|---|
filename |
String
|
json | 文件名 |
domImport(self)
dom导入
Parameters:
Name | Type | Description |
---|---|---|
self |
this
|
表单input:file的this指向 用法:document.getElementById('file').onchange=function(){new QJson().QImport(this)} |
eq(num) → {this}
查询指定下标
Parameters:
Name | Type | Description |
---|---|---|
num |
Number
|
下标 |
Returns:
- Type:
-
this
this
equal(json1, json2)
判断两个json是否相等
Parameters:
Name | Type | Description |
---|---|---|
json1 |
*
|
json1 |
json2 |
*
|
json2 |
export(filename)
node导出
Parameters:
Name | Type | Default | Description |
---|---|---|---|
filename |
String
|
json | 文件名 |
fullJoin(json, key) → {this}
完全连接
(不支持json有子节点的内的完全连接)
Parameters:
Name | Type | Description |
---|---|---|
json |
JSON
|
json数据 |
key |
String
|
Array
|
共同的key值 |
Returns:
- Type:
-
this
this
get(lengthopt) → {Array}
获取值
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
length |
Number
|
<optional> |
0 | 获取的长度 |
Returns:
- Type:
-
Array
json数组
innerJoin(json, key) → {this}
内连接
(不支持json有子节点的内的内连接)
Parameters:
Name | Type | Description |
---|---|---|
json |
JSON
|
json数据 |
key |
String
|
Array
|
共同的key值 |
Returns:
- Type:
-
this
this
insert(json) → {this}
插入数据
Parameters:
Name | Type | Description |
---|---|---|
json |
JSON
|
json |
Returns:
- Type:
-
this
this
用法:insert({id:4,name:'eee'})
insertKey(key, valueopt) → {this}
插入键名
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
String
|
要新增的键名 | ||
value |
*
|
<optional> |
null | 新增的键名给它赋值 |
Returns:
- Type:
-
this
this
用法:insertKey('age',10)
leftJoin(json, key) → {this}
左连接
(不支持json有子节点的内的左连接)
Parameters:
Name | Type | Description |
---|---|---|
json |
JSON
|
json数据 |
key |
String
|
Array
|
共同的key值 |
Returns:
- Type:
-
this
this
limit(startopt, endopt) → {this}
限制查询
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
start |
Number
|
<optional> |
0 | 从start下标开始 |
end |
Number
|
<optional> |
6 | 到end下标结束 |
Returns:
- Type:
-
this
this
用法:limit(0,6)
orderBy(parameters, typeopt) → {this}
排序
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
parameters |
Array
|
String
|
排序参数 | ||
type |
String
|
<optional> |
'asc' | 排序类型 |
Returns:
- Type:
-
this
this
用法:orderBy(['age','name'],'desc')
pagination(pagesopt, lengthopt) → {this}
分页
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pages |
Number
|
<optional> |
0 | 查询第几页 |
length |
Number
|
<optional> |
6 | 每页的数量 |
Returns:
- Type:
-
this
this
用法:pagination(0,6)
解读:查询第一页,每页的数据条数为6条
rightJoin(json, key) → {this}
右连接
(不支持json有子节点的内的右连接)
Parameters:
Name | Type | Description |
---|---|---|
json |
JSON
|
json数据 |
key |
String
|
Array
|
共同的key值 |
Returns:
- Type:
-
this
this
select(key, num) → {this}
查询单个键名
Parameters:
Name | Type | Default | Description |
---|---|---|---|
key |
String
|
键名 | |
num |
Number
|
0 | 下标 |
Returns:
- Type:
-
this
this
unRepeat(arr, key) → {Array}
json去重
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array
|
json数组 |
key |
String
|
key值 |
Returns:
- Type:
-
Array
json数组
update(key, valueopt) → {this}
修改数据
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
String
|
要修改的键名 | ||
value |
*
|
<optional> |
null | 修改的键名给它赋值 |
Returns:
- Type:
-
this
this
用法:update('age',12)
where(obj1, obj2opt, obj2opt) → {this}
查询
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
obj1 |
*
|
参数1 | ||
obj2 |
*
|
<optional> |
null | 参数2 |
obj2 |
*
|
<optional> |
null | 参数3 |
Returns:
- Type:
-
this
this
因为js没有重载的概念,所以用arguments来进行判断传入了几个参数
当只有一个参数时:采用的方法是回调:where((item)=>item.id==1)
当只有两个参数时:查询 -> obj1==obj2
当有三个参数时,obj2是符号:查询 -> obj1 obj2 obj3
whereAll(arr, joinopt)
查询 默认and
用到了eval方法,一些游览器不支持
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
arr |
Array
|
数组 | ||
join |
String
|
<optional> |
'&&' | 连接。&&:和;||:或者 |
Returns:
whereD(key, value) → {this}
查询,默认为==
Parameters:
Name | Type | Description |
---|---|---|
key |
*
|
键名 |
value |
*
|
键值 |
Returns:
- Type:
-
this
this
用法:where('id',1)
解读:json.id==1
输出:[{id: 1, name: "bbb"}]
whereS(key, symbol, value) → {this}
查询
Parameters:
Name | Type | Description |
---|---|---|
key |
*
|
键名 |
symbol |
*
|
符号,当输入其余的符号,默认是== |
value |
*
|
键值 |
Returns:
- Type:
-
this
this
用法:where('id','===',1)
解读:json.id===1
输出:[{id: 1, name: "bbb"}]