xdriver 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +117 -3
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- ## 说明
1
+ # 说明
2
2
 
3
- ### 初始化Connection
3
+ ## 初始化Connection
4
4
 
5
5
  ```javascript
6
6
  import {KeyRange, Driver} from 'xdriver';
@@ -21,7 +21,7 @@ driver.defineTables({
21
21
  const connect = await driver.connect();
22
22
  ```
23
23
 
24
- ### 操作表
24
+ ## 查询操作
25
25
 
26
26
  ```javascript
27
27
  const player = connect.table('player');
@@ -30,4 +30,118 @@ let results = await player.queryByIndex('age_index', KeyRange.between(10, 20));
30
30
  results = await player.queryByIndex('double_index', KeyRange.eq(['女3', 0]));
31
31
  results = await player.query(KeyRange.between(10, 20))
32
32
  results = connect.queryByIndex('tableName', 'indexName', KeyRange.between(10, 20))
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### Connection
38
+
39
+ ```
40
+ /**
41
+ * 查询数据
42
+ * @param table 表名
43
+ * @param query 查询条件
44
+ * @param count 查询数量
45
+ */
46
+ query<R extends Row>(table: string, query?: IDBValidKey | IDBKeyRange, count: number = 1000): Promise<RowPacket<R>>;
47
+
48
+ /**
49
+ * 查询数据
50
+ * @param table 表名
51
+ * @param key 查询条件
52
+ * @param index 索引名称
53
+ * @param count 查询数量
54
+ */
55
+ select<R extends Row>(table: string, key?: IDBValidKey | IDBKeyRange, index?: string, count: number = 1000): Promise<RowPacket<R>>;
56
+
57
+ /**
58
+ * 获取数据
59
+ * @param table 表名
60
+ * @param key 查询条件
61
+ */
62
+ queryByKey<R extends Row>(table: string, key: IDBValidKey | IDBKeyRange): Promise<RowPacket<R>>;
63
+
64
+ /**
65
+ *
66
+ * @param table
67
+ * @param indexName 索引名称
68
+ * @param key key or keyRange (对应的是索引包含的列的数据)
69
+ * @param count 返回的列数
70
+ */
71
+ async queryByIndex<R extends Row>(table: string, indexName: string, key?: IDBValidKey | IDBKeyRange, count?: number): Promise<RowPacket<R>>;
72
+
73
+ /**
74
+ * 获取数据
75
+ * @param table
76
+ * @param id
77
+ * @param indexName
78
+ */
79
+ async queryById<R extends Row>(table: string, id: any | Array<any>, indexName?: string): Promise<R>;
80
+
81
+ /**
82
+ * 获取数据
83
+ * @param table 表名
84
+ * @param key 查询条件
85
+ */
86
+ count(table: string, key: IDBValidKey | IDBKeyRange);
87
+
88
+ /**
89
+ * 插入数据
90
+ * @param table
91
+ * @param data
92
+ */
93
+ insert(table: string, data: Array<Record<string, any>>);
94
+
95
+ /**
96
+ * 更新数据
97
+ * @param table 表名
98
+ * @param modify 更新内容
99
+ * @param key 条件
100
+ */
101
+ update(table: string, modify: Row, key?: IDBValidKey | IDBKeyRange | null);
102
+
103
+ /**
104
+ * 删除数据
105
+ * @param table 表名
106
+ * @param key 索引名称
107
+ */
108
+ delete(table: string, key: IDBValidKey | IDBKeyRange);
109
+
110
+ /**
111
+ * 清空表
112
+ * @param table 表名
113
+ */
114
+ truncate(table: string);
115
+
116
+ /**
117
+ * 获取内存分页模型对象
118
+ * @param table
119
+ * @param pageSize
120
+ */
121
+ getPagination<R extends Row>(table: string, pageSize: number = 10): Promise<Pagination<R>>;
122
+
123
+ /**
124
+ * 扫描数据
125
+ * @param table 表名
126
+ * @param key key or keyRange (对应的是主键的数据)
127
+ * @param direction 游标方向
128
+ * @param indexName 索引名称
129
+ */
130
+ async scan<R extends Row>(table: string, key?: IDBValidKey | IDBKeyRange, direction: IDBCursorDirection = 'next', indexName?: string): Promise<RowPacket<R>>;
131
+
132
+ /**
133
+ * 获取所有数据
134
+ * @param table
135
+ */
136
+ getAllData<R extends Row>(table: string): Promise<Array<R>>;
137
+
138
+ /**
139
+ * 分页查询
140
+ * @param table
141
+ * @param pageNo 页码
142
+ * @param pageSize 每页数量
143
+ * @param key (对应的是主键的数据)
144
+ * @param indexName 索引名称
145
+ */
146
+ async paginate<R extends Row>(table: string, pageNo: number = 1, pageSize: number = 10, key?: IDBValidKey | IDBKeyRange, indexName?: string): Promise<RowPacket<R>>;
33
147
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xdriver",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "A simple driver for IndexDB",
5
5
  "main": "./lib/index",
6
6
  "files": [
@@ -16,7 +16,7 @@
16
16
  "url": "https://gitee.com/xxx/indexdb.git"
17
17
  },
18
18
  "keywords": [
19
- "storage"
19
+ "indexdb"
20
20
  ],
21
21
  "author": "xs",
22
22
  "license": "ISC",