xdriver 1.0.2 → 1.0.6

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.
package/lib/Const.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare class KeyRange {
20
20
  static gt_lt(x: any, y: any): any;
21
21
  static gt_leq(x: any, y: any): any;
22
22
  static geq_lt(x: any, y: any): any;
23
- static eq(x: any, y: any): any;
23
+ static eq(x: any): any;
24
24
  }
25
25
  export declare enum IndexdbStatus {
26
26
  CONNECT_ING = 0,
package/lib/Const.js CHANGED
@@ -42,7 +42,7 @@ export class KeyRange {
42
42
  static geq_lt(x, y) {
43
43
  return DBKeyRange.bound(x, y, false, true);
44
44
  }
45
- static eq(x, y) {
45
+ static eq(x) {
46
46
  return DBKeyRange.only(x);
47
47
  }
48
48
  }
package/lib/Table.d.ts CHANGED
@@ -22,9 +22,10 @@ export default class Table {
22
22
  keys(keyRange?: KeyRange, limit?: number): any;
23
23
  count(keyRange?: KeyRange): any;
24
24
  query(keyRange?: KeyRange, limit?: number): any;
25
+ select(where: any, options?: any): any;
25
26
  queryByKey(key: any): any;
26
27
  fetch(keyRange?: KeyRange, direction?: CursorDirection): Promise<unknown>;
27
- queryByIndex(name: string, key: any): any;
28
+ queryByIndex(name: string, key: any, count?: number): any;
28
29
  deplete(direction?: any): Promise<unknown>;
29
30
  multiple(indexName: string, each: Function, keyRange?: KeyRange, cursorDirection?: CursorDirection): Promise<unknown>;
30
31
  }
package/lib/Table.js CHANGED
@@ -90,6 +90,16 @@ export default class Table {
90
90
  const request = _getObjectStore(this).getAll(keyRange, limit);
91
91
  return _request(request);
92
92
  }
93
+ select(where, options) {
94
+ if (!where) {
95
+ return this.query();
96
+ }
97
+ let { index = '', limit = void 0, useIndex = false } = options;
98
+ if (useIndex && index) {
99
+ return this.queryByIndex(index, where, limit);
100
+ }
101
+ return this.query(where, limit);
102
+ }
93
103
  queryByKey(key) {
94
104
  const request = _getObjectStore(this).get(key);
95
105
  return _request(request);
@@ -111,10 +121,10 @@ export default class Table {
111
121
  });
112
122
  });
113
123
  }
114
- queryByIndex(name, key) {
124
+ queryByIndex(name, key, count) {
115
125
  const store = _getObjectStore(this);
116
126
  const index = store.index(name);
117
- return _request(index.getAll(key));
127
+ return _request(index.getAll(key, count));
118
128
  }
119
129
  deplete(direction = CursorDirection.NEXT) {
120
130
  const store = _getObjectStore(this, TransactionMode.READ_WRITE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xdriver",
3
- "version": "1.0.02",
3
+ "version": "1.0.06",
4
4
  "description": "A simple driver for IndexDB",
5
5
  "main": "./lib/index",
6
6
  "files": [