@anfenn/dync 1.0.2 → 1.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.
- package/README.md +33 -15
- package/dist/{chunk-66PSQW4D.js → chunk-PCA4XM2N.js} +17 -17
- package/dist/chunk-PCA4XM2N.js.map +1 -0
- package/dist/{dexie-Bv-fV10P.d.cts → dexie-1_xyU5MV.d.cts} +41 -38
- package/dist/{dexie-DJFApKsM.d.ts → dexie-ChZ0o0Sz.d.ts} +41 -38
- package/dist/dexie.cjs +40 -40
- package/dist/dexie.cjs.map +1 -1
- package/dist/dexie.d.cts +1 -1
- package/dist/dexie.d.ts +1 -1
- package/dist/dexie.js +40 -40
- package/dist/dexie.js.map +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{index.shared-CkYsQYyn.d.ts → index.shared-Byhq6TyU.d.ts} +1 -1
- package/dist/{index.shared-BGwvMH8f.d.cts → index.shared-DsDBNWlz.d.cts} +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/package.json +9 -1
- package/src/core/tableEnhancers.ts +17 -17
- package/src/storage/dexie/DexieAdapter.ts +2 -2
- package/src/storage/dexie/{DexieStorageCollection.ts → DexieCollection.ts} +12 -12
- package/src/storage/dexie/DexieTable.ts +123 -0
- package/src/storage/dexie/{DexieStorageWhereClause.ts → DexieWhereClause.ts} +21 -21
- package/src/storage/dexie/index.ts +3 -3
- package/src/storage/memory/MemoryTable.ts +40 -40
- package/src/storage/sqlite/SQLiteTable.ts +34 -36
- package/src/storage/types.ts +22 -19
- package/dist/chunk-66PSQW4D.js.map +0 -1
- package/src/storage/dexie/DexieStorageTable.ts +0 -123
package/dist/react/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ApiFunctions, h as SyncOptions, B as BatchSync, D as Dync, i as SyncState } from '../index.shared-
|
|
2
|
-
import { c as StorageAdapter } from '../dexie-
|
|
1
|
+
import { a as ApiFunctions, h as SyncOptions, B as BatchSync, D as Dync, i as SyncState } from '../index.shared-DsDBNWlz.cjs';
|
|
2
|
+
import { c as StorageAdapter } from '../dexie-1_xyU5MV.cjs';
|
|
3
3
|
import '../types-CSbIAfu2.cjs';
|
|
4
4
|
import 'dexie';
|
|
5
5
|
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ApiFunctions, h as SyncOptions, B as BatchSync, D as Dync, i as SyncState } from '../index.shared-
|
|
2
|
-
import { c as StorageAdapter } from '../dexie-
|
|
1
|
+
import { a as ApiFunctions, h as SyncOptions, B as BatchSync, D as Dync, i as SyncState } from '../index.shared-Byhq6TyU.js';
|
|
2
|
+
import { c as StorageAdapter } from '../dexie-ChZ0o0Sz.js';
|
|
3
3
|
import '../types-CSbIAfu2.js';
|
|
4
4
|
import 'dexie';
|
|
5
5
|
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anfenn/dync",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Write once, run IndexedDB & SQLite with sync anywhere - React, React Native, Expo, Capacitor, Electron & Node.js",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "Adam Fennell",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/anfen/dync.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/anfen/dync/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/anfen/dync#readme",
|
|
9
17
|
"type": "module",
|
|
10
18
|
"react-native": "./src/index.native.ts",
|
|
11
19
|
"exports": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLocalId } from '../helpers';
|
|
2
2
|
import { SyncAction, type MutationEvent, type SyncedRecord } from '../types';
|
|
3
|
-
import type { StorageTable } from '../storage/types';
|
|
3
|
+
import type { AddItem, StorageTable } from '../storage/types';
|
|
4
4
|
import { DYNC_STATE_TABLE, type StateHelpers } from './StateManager';
|
|
5
5
|
import type { WithTransaction } from './types';
|
|
6
6
|
export type EmitMutation = (event: MutationEvent) => void;
|
|
@@ -20,8 +20,8 @@ export function wrapWithMutationEmitter<T>(table: StorageTable<T>, tableName: st
|
|
|
20
20
|
const rawBulkDelete = table.raw.bulkDelete;
|
|
21
21
|
const rawClear = table.raw.clear;
|
|
22
22
|
|
|
23
|
-
table.add = async (item: T) => {
|
|
24
|
-
const result = await rawAdd(item);
|
|
23
|
+
table.add = async (item: AddItem<T>) => {
|
|
24
|
+
const result = await rawAdd(item as T);
|
|
25
25
|
emitMutation({ type: 'add', tableName, keys: [result] });
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
@@ -32,7 +32,7 @@ export function wrapWithMutationEmitter<T>(table: StorageTable<T>, tableName: st
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
table.update = async (key:
|
|
35
|
+
table.update = async (key: string, changes: Partial<T>) => {
|
|
36
36
|
const result = await rawUpdate(key, changes);
|
|
37
37
|
if (result > 0) {
|
|
38
38
|
emitMutation({ type: 'update', tableName, keys: [key] });
|
|
@@ -40,13 +40,13 @@ export function wrapWithMutationEmitter<T>(table: StorageTable<T>, tableName: st
|
|
|
40
40
|
return result;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
table.delete = async (key:
|
|
43
|
+
table.delete = async (key: string) => {
|
|
44
44
|
await rawDelete(key);
|
|
45
45
|
emitMutation({ type: 'delete', tableName, keys: [key] });
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
table.bulkAdd = async (items: T[]) => {
|
|
49
|
-
const result = await rawBulkAdd(items);
|
|
48
|
+
table.bulkAdd = async (items: AddItem<T>[]) => {
|
|
49
|
+
const result = await rawBulkAdd(items as T[]);
|
|
50
50
|
if (items.length > 0) {
|
|
51
51
|
emitMutation({ type: 'add', tableName });
|
|
52
52
|
}
|
|
@@ -61,7 +61,7 @@ export function wrapWithMutationEmitter<T>(table: StorageTable<T>, tableName: st
|
|
|
61
61
|
return result;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
table.bulkUpdate = async (keysAndChanges: Array<{ key:
|
|
64
|
+
table.bulkUpdate = async (keysAndChanges: Array<{ key: string; changes: Partial<T> }>) => {
|
|
65
65
|
const result = await rawBulkUpdate(keysAndChanges);
|
|
66
66
|
if (result > 0) {
|
|
67
67
|
emitMutation({ type: 'update', tableName, keys: keysAndChanges.map((kc) => kc.key) });
|
|
@@ -69,7 +69,7 @@ export function wrapWithMutationEmitter<T>(table: StorageTable<T>, tableName: st
|
|
|
69
69
|
return result;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
table.bulkDelete = async (keys:
|
|
72
|
+
table.bulkDelete = async (keys: string[]) => {
|
|
73
73
|
await rawBulkDelete(keys);
|
|
74
74
|
if (keys.length > 0) {
|
|
75
75
|
emitMutation({ type: 'delete', tableName });
|
|
@@ -134,7 +134,7 @@ export function enhanceSyncTable<T>({ table, tableName, withTransaction, state,
|
|
|
134
134
|
updated_at: new Date().toISOString(),
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
let result
|
|
137
|
+
let result!: string;
|
|
138
138
|
await withTransaction('rw', [tableName, DYNC_STATE_TABLE], async () => {
|
|
139
139
|
result = await rawAdd(syncedItem);
|
|
140
140
|
|
|
@@ -162,7 +162,7 @@ export function enhanceSyncTable<T>({ table, tableName, withTransaction, state,
|
|
|
162
162
|
updated_at: new Date().toISOString(),
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
let result
|
|
165
|
+
let result!: string;
|
|
166
166
|
let isUpdate = false;
|
|
167
167
|
let existingRecord: any;
|
|
168
168
|
|
|
@@ -248,8 +248,8 @@ export function enhanceSyncTable<T>({ table, tableName, withTransaction, state,
|
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
|
|
251
|
-
const wrappedBulkAdd = async (items: any[]) => {
|
|
252
|
-
if (items.length === 0) return;
|
|
251
|
+
const wrappedBulkAdd = async (items: any[]): Promise<string[]> => {
|
|
252
|
+
if (items.length === 0) return [];
|
|
253
253
|
|
|
254
254
|
const now = new Date().toISOString();
|
|
255
255
|
const syncedItems = items.map((item) => {
|
|
@@ -261,7 +261,7 @@ export function enhanceSyncTable<T>({ table, tableName, withTransaction, state,
|
|
|
261
261
|
};
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
-
let result
|
|
264
|
+
let result!: string[];
|
|
265
265
|
await withTransaction('rw', [tableName, DYNC_STATE_TABLE], async () => {
|
|
266
266
|
result = await rawBulkAdd(syncedItems);
|
|
267
267
|
|
|
@@ -281,8 +281,8 @@ export function enhanceSyncTable<T>({ table, tableName, withTransaction, state,
|
|
|
281
281
|
return result;
|
|
282
282
|
};
|
|
283
283
|
|
|
284
|
-
const wrappedBulkPut = async (items: any[]) => {
|
|
285
|
-
if (items.length === 0) return;
|
|
284
|
+
const wrappedBulkPut = async (items: any[]): Promise<string[]> => {
|
|
285
|
+
if (items.length === 0) return [];
|
|
286
286
|
|
|
287
287
|
const now = new Date().toISOString();
|
|
288
288
|
const syncedItems = items.map((item) => {
|
|
@@ -295,7 +295,7 @@ export function enhanceSyncTable<T>({ table, tableName, withTransaction, state,
|
|
|
295
295
|
});
|
|
296
296
|
const localIds = syncedItems.map((i) => i._localId);
|
|
297
297
|
|
|
298
|
-
let result
|
|
298
|
+
let result!: string[];
|
|
299
299
|
await withTransaction('rw', [tableName, DYNC_STATE_TABLE], async (tables) => {
|
|
300
300
|
const txTable = tables[tableName]!;
|
|
301
301
|
|
|
@@ -3,7 +3,7 @@ import type { StorageAdapter, StorageTable, StorageTransactionContext, Transacti
|
|
|
3
3
|
import type { StorageSchemaDefinitionOptions } from '../sqlite/types';
|
|
4
4
|
import type { TableSchemaDefinition } from '../sqlite/schema';
|
|
5
5
|
import { DexieQueryContext } from './DexieQueryContext';
|
|
6
|
-
import {
|
|
6
|
+
import { DexieTable } from './DexieTable';
|
|
7
7
|
|
|
8
8
|
export class DexieAdapter implements StorageAdapter {
|
|
9
9
|
readonly type = 'DexieAdapter';
|
|
@@ -55,7 +55,7 @@ export class DexieAdapter implements StorageAdapter {
|
|
|
55
55
|
table<T = any>(name: string): StorageTable<T> {
|
|
56
56
|
if (!this.tableCache.has(name)) {
|
|
57
57
|
const table = this.db.table<T>(name);
|
|
58
|
-
this.tableCache.set(name, new
|
|
58
|
+
this.tableCache.set(name, new DexieTable(table));
|
|
59
59
|
}
|
|
60
60
|
return this.tableCache.get(name)! as StorageTable<T>;
|
|
61
61
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Collection
|
|
1
|
+
import type { Collection } from 'dexie';
|
|
2
2
|
import type { StorageCollection, StorageWhereClause } from '../types';
|
|
3
3
|
import { normalizeIndexName } from './helpers';
|
|
4
|
-
import {
|
|
4
|
+
import { DexieWhereClause } from './DexieWhereClause';
|
|
5
5
|
|
|
6
|
-
export class
|
|
7
|
-
private readonly collection:
|
|
6
|
+
export class DexieCollection<T = any> implements StorageCollection<T> {
|
|
7
|
+
private readonly collection: Collection<T, any, T>;
|
|
8
8
|
|
|
9
|
-
constructor(collection:
|
|
9
|
+
constructor(collection: Collection<T, any, T>) {
|
|
10
10
|
this.collection = collection;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -79,31 +79,31 @@ export class DexieStorageCollection<T = any> implements StorageCollection<T> {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
distinct(): StorageCollection<T> {
|
|
82
|
-
return new
|
|
82
|
+
return new DexieCollection(this.collection.distinct());
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
jsFilter(predicate: (item: T) => boolean): StorageCollection<T> {
|
|
86
|
-
return new
|
|
86
|
+
return new DexieCollection(this.collection.filter(predicate));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
or(index: string): StorageWhereClause<T> {
|
|
90
|
-
return new
|
|
90
|
+
return new DexieWhereClause(this.collection.or(normalizeIndexName(index)));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
clone(props?: Record<string, unknown>): StorageCollection<T> {
|
|
94
|
-
return new
|
|
94
|
+
return new DexieCollection(this.collection.clone(props));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
reverse(): StorageCollection<T> {
|
|
98
|
-
return new
|
|
98
|
+
return new DexieCollection(this.collection.reverse());
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
offset(offset: number): StorageCollection<T> {
|
|
102
|
-
return new
|
|
102
|
+
return new DexieCollection(this.collection.offset(offset));
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
limit(count: number): StorageCollection<T> {
|
|
106
|
-
return new
|
|
106
|
+
return new DexieCollection(this.collection.limit(count));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
toCollection(): StorageCollection<T> {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Table } from 'dexie';
|
|
2
|
+
import type { AddItem, StorageCollection, StorageTable, StorageWhereClause } from '../types';
|
|
3
|
+
import { normalizeIndexName } from './helpers';
|
|
4
|
+
import { DexieCollection } from './DexieCollection';
|
|
5
|
+
import { DexieWhereClause } from './DexieWhereClause';
|
|
6
|
+
|
|
7
|
+
export class DexieTable<T = any> implements StorageTable<T> {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly schema: unknown;
|
|
10
|
+
readonly primaryKey: unknown;
|
|
11
|
+
readonly hook: unknown;
|
|
12
|
+
readonly raw = Object.freeze({
|
|
13
|
+
add: (item: T): Promise<string> => this.table.add(item) as Promise<string>,
|
|
14
|
+
put: (item: T): Promise<string> => this.table.put(item) as Promise<string>,
|
|
15
|
+
update: (key: string, changes: Partial<T>) => this.table.update(key as any, changes as any),
|
|
16
|
+
delete: (key: string) => this.table.delete(key as any),
|
|
17
|
+
get: (key: string) => this.table.get(key as any),
|
|
18
|
+
bulkAdd: (items: T[]): Promise<string[]> => this.table.bulkAdd(items, { allKeys: true }) as Promise<string[]>,
|
|
19
|
+
bulkPut: (items: T[]): Promise<string[]> => this.table.bulkPut(items, { allKeys: true }) as Promise<string[]>,
|
|
20
|
+
bulkUpdate: (keysAndChanges: Array<{ key: string; changes: Partial<T> }>) => this.table.bulkUpdate(keysAndChanges as any),
|
|
21
|
+
bulkDelete: (keys: string[]) => this.table.bulkDelete(keys as any),
|
|
22
|
+
clear: () => this.table.clear(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
private readonly table: Table<T, any, T>;
|
|
26
|
+
|
|
27
|
+
constructor(table: Table<T, any, T>) {
|
|
28
|
+
this.table = table;
|
|
29
|
+
this.name = table.name;
|
|
30
|
+
this.schema = table.schema;
|
|
31
|
+
this.primaryKey = table.schema?.primKey;
|
|
32
|
+
this.hook = table.hook;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
add(item: AddItem<T>): Promise<string> {
|
|
36
|
+
return this.table.add(item as T);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
put(item: T): Promise<string> {
|
|
40
|
+
return this.table.put(item);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
update(key: string, changes: Partial<T>): Promise<number> {
|
|
44
|
+
return this.table.update(key as any, changes as any);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
delete(key: string): Promise<void> {
|
|
48
|
+
return this.table.delete(key as any).then(() => undefined);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
clear(): Promise<void> {
|
|
52
|
+
return this.table.clear();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get(key: string): Promise<T | undefined> {
|
|
56
|
+
return this.table.get(key as any);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
toArray(): Promise<T[]> {
|
|
60
|
+
return this.table.toArray();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
count(): Promise<number> {
|
|
64
|
+
return this.table.count();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
bulkAdd(items: AddItem<T>[]): Promise<string[]> {
|
|
68
|
+
return this.table.bulkAdd(items as T[], { allKeys: true }) as Promise<string[]>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
bulkPut(items: T[]): Promise<string[]> {
|
|
72
|
+
return this.table.bulkPut(items, { allKeys: true }) as Promise<string[]>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
bulkGet(keys: string[]): Promise<Array<T | undefined>> {
|
|
76
|
+
return this.table.bulkGet(keys as any);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bulkUpdate(keysAndChanges: Array<{ key: string; changes: Partial<T> }>): Promise<number> {
|
|
80
|
+
return this.table.bulkUpdate(keysAndChanges as any);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
bulkDelete(keys: string[]): Promise<void> {
|
|
84
|
+
return this.table.bulkDelete(keys as any);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
where(index: string | string[]): StorageWhereClause<T> {
|
|
88
|
+
return new DexieWhereClause(this.table.where(normalizeIndexName(index)));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
orderBy(index: string | string[]): StorageCollection<T> {
|
|
92
|
+
return new DexieCollection(this.table.orderBy(normalizeIndexName(index)));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
reverse(): StorageCollection<T> {
|
|
96
|
+
return new DexieCollection(this.table.reverse());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
offset(offset: number): StorageCollection<T> {
|
|
100
|
+
return new DexieCollection(this.table.offset(offset));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
limit(count: number): StorageCollection<T> {
|
|
104
|
+
return new DexieCollection(this.table.limit(count));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
mapToClass(ctor: new (...args: any[]) => any): StorageTable<T> {
|
|
108
|
+
this.table.mapToClass(ctor as any);
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async each(callback: (item: T) => void | Promise<void>): Promise<void> {
|
|
113
|
+
const tasks: Array<void | Promise<void>> = [];
|
|
114
|
+
await this.table.each((item) => {
|
|
115
|
+
tasks.push(callback(item));
|
|
116
|
+
});
|
|
117
|
+
await Promise.all(tasks.map((task) => (task ? Promise.resolve(task) : Promise.resolve())));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
jsFilter(predicate: (item: T) => boolean): StorageCollection<T> {
|
|
121
|
+
return new DexieCollection(this.table.filter(predicate));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import type { WhereClause
|
|
1
|
+
import type { WhereClause } from 'dexie';
|
|
2
2
|
import type { StorageCollection, StorageWhereClause } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { DexieCollection } from './DexieCollection';
|
|
4
4
|
|
|
5
|
-
export class
|
|
6
|
-
private readonly clause:
|
|
5
|
+
export class DexieWhereClause<T = any> implements StorageWhereClause<T> {
|
|
6
|
+
private readonly clause: WhereClause<T, any, T>;
|
|
7
7
|
|
|
8
|
-
constructor(clause:
|
|
8
|
+
constructor(clause: WhereClause<T, any, T>) {
|
|
9
9
|
this.clause = clause;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
equals(value: any): StorageCollection<T> {
|
|
13
|
-
return new
|
|
13
|
+
return new DexieCollection(this.clause.equals(value));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
above(value: any): StorageCollection<T> {
|
|
17
|
-
return new
|
|
17
|
+
return new DexieCollection(this.clause.above(value));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
aboveOrEqual(value: any): StorageCollection<T> {
|
|
21
|
-
return new
|
|
21
|
+
return new DexieCollection(this.clause.aboveOrEqual(value));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
below(value: any): StorageCollection<T> {
|
|
25
|
-
return new
|
|
25
|
+
return new DexieCollection(this.clause.below(value));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
belowOrEqual(value: any): StorageCollection<T> {
|
|
29
|
-
return new
|
|
29
|
+
return new DexieCollection(this.clause.belowOrEqual(value));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): StorageCollection<T> {
|
|
33
|
-
return new
|
|
33
|
+
return new DexieCollection(this.clause.between(lower, upper, includeLower, includeUpper));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
inAnyRange(ranges: Array<[any, any]>, options?: { includeLower?: boolean; includeUpper?: boolean }): StorageCollection<T> {
|
|
@@ -40,58 +40,58 @@ export class DexieStorageWhereClause<T = any> implements StorageWhereClause<T> {
|
|
|
40
40
|
includeUppers: options.includeUpper,
|
|
41
41
|
}
|
|
42
42
|
: undefined;
|
|
43
|
-
return new
|
|
43
|
+
return new DexieCollection(this.clause.inAnyRange(ranges as any, normalizedOptions));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
startsWith(prefix: string): StorageCollection<T> {
|
|
47
|
-
return new
|
|
47
|
+
return new DexieCollection(this.clause.startsWith(prefix));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
startsWithIgnoreCase(prefix: string): StorageCollection<T> {
|
|
51
|
-
return new
|
|
51
|
+
return new DexieCollection(this.clause.startsWithIgnoreCase(prefix));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
startsWithAnyOf(...prefixes: string[]): StorageCollection<T>;
|
|
55
55
|
startsWithAnyOf(prefixes: string[]): StorageCollection<T>;
|
|
56
56
|
startsWithAnyOf(...args: any[]): StorageCollection<T> {
|
|
57
57
|
const values = this.flattenArgs<string>(args);
|
|
58
|
-
return new
|
|
58
|
+
return new DexieCollection(this.clause.startsWithAnyOf(...values));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
startsWithAnyOfIgnoreCase(...prefixes: string[]): StorageCollection<T>;
|
|
62
62
|
startsWithAnyOfIgnoreCase(prefixes: string[]): StorageCollection<T>;
|
|
63
63
|
startsWithAnyOfIgnoreCase(...args: any[]): StorageCollection<T> {
|
|
64
64
|
const values = this.flattenArgs<string>(args);
|
|
65
|
-
return new
|
|
65
|
+
return new DexieCollection(this.clause.startsWithAnyOfIgnoreCase(...values));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
equalsIgnoreCase(value: string): StorageCollection<T> {
|
|
69
|
-
return new
|
|
69
|
+
return new DexieCollection(this.clause.equalsIgnoreCase(value));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
anyOf(...values: any[]): StorageCollection<T>;
|
|
73
73
|
anyOf(values: any[]): StorageCollection<T>;
|
|
74
74
|
anyOf(...args: any[]): StorageCollection<T> {
|
|
75
75
|
const values = this.flattenArgs<any>(args);
|
|
76
|
-
return new
|
|
76
|
+
return new DexieCollection(this.clause.anyOf(...values));
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
anyOfIgnoreCase(...values: string[]): StorageCollection<T>;
|
|
80
80
|
anyOfIgnoreCase(values: string[]): StorageCollection<T>;
|
|
81
81
|
anyOfIgnoreCase(...args: any[]): StorageCollection<T> {
|
|
82
82
|
const values = this.flattenArgs<string>(args);
|
|
83
|
-
return new
|
|
83
|
+
return new DexieCollection(this.clause.anyOfIgnoreCase(...values));
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
noneOf(...values: any[]): StorageCollection<T>;
|
|
87
87
|
noneOf(values: any[]): StorageCollection<T>;
|
|
88
88
|
noneOf(...args: any[]): StorageCollection<T> {
|
|
89
89
|
const values = this.flattenArgs<any>(args);
|
|
90
|
-
return new
|
|
90
|
+
return new DexieCollection(this.clause.noneOf(values as any));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
notEqual(value: any): StorageCollection<T> {
|
|
94
|
-
return new
|
|
94
|
+
return new DexieCollection(this.clause.notEqual(value));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
private flattenArgs<TValue>(args: any[]): TValue[] {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Export all classes
|
|
2
2
|
export { DexieAdapter } from './DexieAdapter';
|
|
3
3
|
export { DexieQueryContext } from './DexieQueryContext';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { DexieCollection } from './DexieCollection';
|
|
5
|
+
export { DexieWhereClause } from './DexieWhereClause';
|
|
6
|
+
export { DexieTable } from './DexieTable';
|
|
7
7
|
export { normalizeIndexName } from './helpers';
|