dexie 3.2.0-rc.2 → 3.2.1-beta.2
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/CONTRIBUTING.md +1 -1
- package/README.md +54 -46
- package/dist/dexie.d.ts +42 -37
- package/dist/dexie.js +147 -73
- package/dist/dexie.js.map +1 -1
- package/dist/dexie.min.js +1 -1
- package/dist/dexie.min.js.map +1 -1
- package/dist/dexie.mjs +146 -73
- package/dist/dexie.mjs.map +1 -1
- package/dist/modern/dexie.min.mjs +1 -1
- package/dist/modern/dexie.min.mjs.map +1 -1
- package/dist/modern/dexie.mjs +132 -64
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.mjs +7 -0
- package/import-wrapper.mjs +7 -0
- package/package.json +29 -4
package/CONTRIBUTING.md
CHANGED
|
@@ -6,7 +6,7 @@ We appreciate contributions in forms of:
|
|
|
6
6
|
* issues
|
|
7
7
|
* help answering questions in [issues](https://github.com/dfahlander/Dexie.js/issues) and on [stackoverflow](https://stackexchange.com/filters/233583/dexie-stackoverflow)
|
|
8
8
|
* fixing bugs via pull-requests
|
|
9
|
-
* developing addons or other [derived work](
|
|
9
|
+
* developing addons or other [derived work](https://dexie.org/docs/DerivedWork)
|
|
10
10
|
* promoting Dexie.js
|
|
11
11
|
* sharing ideas
|
|
12
12
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Dexie.js
|
|
2
2
|
========
|
|
3
3
|
|
|
4
|
-
[![NPM Version][npm-image]][npm-url] [](https://travis-ci.com/dfahlander/Dexie.js)[](https://travis-ci.com/dfahlander/Dexie.js)[](https://www.browserstack.com)
|
|
5
5
|
|
|
6
|
-
Dexie.js is a wrapper library for indexedDB - the standard database in the browser.
|
|
6
|
+
Dexie.js is a wrapper library for indexedDB - the standard database in the browser. https://dexie.org
|
|
7
7
|
|
|
8
8
|
#### Why?
|
|
9
9
|
Dexie solves three main issues with the native IndexedDB API:
|
|
@@ -44,17 +44,48 @@ Dexie provides a neat database API with a well thought-through API design, robus
|
|
|
44
44
|
</head>
|
|
45
45
|
</html>
|
|
46
46
|
```
|
|
47
|
-
Yes, it's that simple.
|
|
47
|
+
Yes, it's that simple.
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An equivalent modern version (works in all modern browsers):
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
```html
|
|
52
|
+
<!doctype html>
|
|
53
|
+
<html>
|
|
54
|
+
<head>
|
|
55
|
+
<script type="module">
|
|
56
|
+
import Dexie from "https://unpkg.com/dexie@latest/dist/modern/dexie.mjs";
|
|
57
|
+
//
|
|
58
|
+
// Declare Database
|
|
59
|
+
//
|
|
60
|
+
const db = new Dexie("FriendDatabase");
|
|
61
|
+
db.version(1).stores({
|
|
62
|
+
friends: "++id,name,age"
|
|
63
|
+
});
|
|
52
64
|
|
|
53
|
-
|
|
65
|
+
//
|
|
66
|
+
// Manipulate and Query Database
|
|
67
|
+
//
|
|
68
|
+
try {
|
|
69
|
+
await db.friends.add({name: "Josephine", age: 21});
|
|
70
|
+
const youngFriends = await db.friends.where("age").below(25).toArray();
|
|
71
|
+
alert (`My young friends: ${JSON.stringify(youngFriends)}`);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
alert (`Error: ${e}`);
|
|
74
|
+
}
|
|
75
|
+
</script>
|
|
76
|
+
</head>
|
|
77
|
+
</html>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
[Tutorial](https://dexie.org/docs/Tutorial)
|
|
81
|
+
|
|
82
|
+
[API Reference](https://dexie.org/docs/API-Reference)
|
|
83
|
+
|
|
84
|
+
[Samples](https://dexie.org/docs/Samples)
|
|
54
85
|
|
|
55
86
|
### Performance
|
|
56
87
|
|
|
57
|
-
Dexie has kick-ass performance. Its [bulk methods](
|
|
88
|
+
Dexie has kick-ass performance. Its [bulk methods](https://dexie.org/docs/Table/Table.bulkPut()) take advantage of a lesser-known feature in IndexedDB that makes it possible to store stuff without listening to every onsuccess event. This speeds up the performance to a maximum.
|
|
58
89
|
|
|
59
90
|
#### Supported operations
|
|
60
91
|
```js
|
|
@@ -108,42 +139,12 @@ uniqueKeys(): Promise;
|
|
|
108
139
|
until(filter: (value) => boolean, includeStopEntry?: boolean): Collection;
|
|
109
140
|
update(key: Key, changes: { [keyPath: string]: any }): Promise;
|
|
110
141
|
```
|
|
111
|
-
This is a mix of methods from [WhereClause](
|
|
112
|
-
|
|
113
|
-
#### Hello World (ES2016 / ES7)
|
|
114
|
-
```js
|
|
115
|
-
import Dexie from 'dexie';
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
// Declare Database
|
|
119
|
-
//
|
|
120
|
-
const db = new Dexie("FriendDatabase");
|
|
121
|
-
db.version(1).stores({ friends: "++id,name,age" });
|
|
122
|
-
|
|
123
|
-
db.transaction('rw', db.friends, async() => {
|
|
124
|
-
|
|
125
|
-
// Make sure we have something in DB:
|
|
126
|
-
if ((await db.friends.where({name: 'Josephine'}).count()) === 0) {
|
|
127
|
-
const id = await db.friends.add({name: "Josephine", age: 21});
|
|
128
|
-
alert (`Addded friend with id ${id}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Query:
|
|
132
|
-
const youngFriends = await db.friends.where("age").below(25).toArray();
|
|
133
|
-
|
|
134
|
-
// Show result:
|
|
135
|
-
alert ("My young friends: " + JSON.stringify(youngFriends));
|
|
136
|
-
|
|
137
|
-
}).catch(e => {
|
|
138
|
-
alert(e.stack || e);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
+
This is a mix of methods from [WhereClause](https://dexie.org/docs/WhereClause/WhereClause), [Table](https://dexie.org/docs/Table/Table) and [Collection](https://dexie.org/docs/Collection/Collection). Dive into the [API reference](https://dexie.org/docs/API-Reference) to see the details.
|
|
142
143
|
|
|
143
144
|
#### Hello World (Typescript)
|
|
144
145
|
|
|
145
146
|
```js
|
|
146
|
-
import Dexie from 'dexie';
|
|
147
|
+
import Dexie, { Table } from 'dexie';
|
|
147
148
|
|
|
148
149
|
interface Friend {
|
|
149
150
|
id?: number;
|
|
@@ -155,14 +156,13 @@ interface Friend {
|
|
|
155
156
|
// Declare Database
|
|
156
157
|
//
|
|
157
158
|
class FriendDatabase extends Dexie {
|
|
158
|
-
public friends
|
|
159
|
+
public friends!: Table<Friend, number>; // id is number in this case
|
|
159
160
|
|
|
160
161
|
public constructor() {
|
|
161
162
|
super("FriendDatabase");
|
|
162
163
|
this.version(1).stores({
|
|
163
164
|
friends: "++id,name,age"
|
|
164
165
|
});
|
|
165
|
-
this.friends = this.table("friends");
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -189,17 +189,17 @@ db.transaction('rw', db.friends, async() => {
|
|
|
189
189
|
|
|
190
190
|
Samples
|
|
191
191
|
-------
|
|
192
|
-
|
|
192
|
+
https://dexie.org/docs/Samples
|
|
193
193
|
|
|
194
194
|
https://github.com/dfahlander/Dexie.js/tree/master/samples
|
|
195
195
|
|
|
196
196
|
Knowledge Base
|
|
197
197
|
-----
|
|
198
|
-
[
|
|
198
|
+
[https://dexie.org/docs/Questions-and-Answers](https://dexie.org/docs/Questions-and-Answers)
|
|
199
199
|
|
|
200
200
|
Website
|
|
201
201
|
-------
|
|
202
|
-
[
|
|
202
|
+
[https://dexie.org](https://dexie.org)
|
|
203
203
|
|
|
204
204
|
Install over npm
|
|
205
205
|
----------------
|
|
@@ -212,13 +212,21 @@ Download
|
|
|
212
212
|
--------
|
|
213
213
|
For those who don't like package managers, here's the download links:
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
### Legacy:
|
|
216
|
+
https://unpkg.com/dexie@latest/dist/dexie.min.js
|
|
216
217
|
|
|
217
|
-
https://unpkg.com/dexie@latest/dist/dexie.js.map
|
|
218
|
+
https://unpkg.com/dexie@latest/dist/dexie.min.js.map
|
|
218
219
|
|
|
220
|
+
### Modern:
|
|
221
|
+
https://unpkg.com/dexie@latest/dist/modern/dexie.min.mjs
|
|
222
|
+
|
|
223
|
+
https://unpkg.com/dexie@latest/dist/modern/dexie.min.mjs.map
|
|
224
|
+
|
|
225
|
+
### Typings:
|
|
219
226
|
https://unpkg.com/dexie@latest/dist/dexie.d.ts
|
|
220
227
|
|
|
221
228
|
|
|
229
|
+
|
|
222
230
|
Contributing
|
|
223
231
|
============
|
|
224
232
|
Here is a little cheat-sheet for how to symlink your app's `node_modules/dexie` to a place where you can edit the source, version control your changes and create pull requests back to Dexie. Assuming you've already ran `npm install dexie --save` for the app your are developing.
|
package/dist/dexie.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 3.2.
|
|
7
|
+
* Version 3.2.1-beta.2, Wed Jan 05 2022
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* https://dexie.org
|
|
10
10
|
*
|
|
11
11
|
* Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
|
|
12
12
|
*/
|
|
13
|
-
// Generated by dts-bundle-generator v5.
|
|
13
|
+
// Generated by dts-bundle-generator v5.9.0
|
|
14
14
|
|
|
15
15
|
export interface IndexSpec {
|
|
16
16
|
name: string;
|
|
@@ -551,9 +551,9 @@ export interface DBCoreIndex {
|
|
|
551
551
|
readonly name: string | null;
|
|
552
552
|
/** True if this index represents the primary key */
|
|
553
553
|
readonly isPrimaryKey?: boolean;
|
|
554
|
-
/** True if this index represents the primary key and is not inbound (
|
|
554
|
+
/** True if this index represents the primary key and is not inbound (https://dexie.org/docs/inbound) */
|
|
555
555
|
readonly outbound?: boolean;
|
|
556
|
-
/** True if and only if keyPath is an array (
|
|
556
|
+
/** True if and only if keyPath is an array (https://dexie.org/docs/Compound-Index) */
|
|
557
557
|
readonly compound?: boolean;
|
|
558
558
|
/** keyPath, null for primary key, string for single-property indexes, Array<string> for compound indexes */
|
|
559
559
|
readonly keyPath: null | string | string[];
|
|
@@ -571,7 +571,6 @@ export interface DBCore {
|
|
|
571
571
|
// Transaction and Object Store
|
|
572
572
|
transaction(stores: string[], mode: "readonly" | "readwrite", options?: DbCoreTransactionOptions): DBCoreTransaction;
|
|
573
573
|
// Utility methods
|
|
574
|
-
cmp(a: any, b: any): number;
|
|
575
574
|
readonly MIN_KEY: any;
|
|
576
575
|
readonly MAX_KEY: any;
|
|
577
576
|
readonly schema: DBCoreSchema;
|
|
@@ -791,7 +790,7 @@ export interface Dexie extends Database {
|
|
|
791
790
|
* Common base class for all errors originating from Dexie.js except TypeError,
|
|
792
791
|
* SyntaxError and RangeError.
|
|
793
792
|
*
|
|
794
|
-
*
|
|
793
|
+
* https://dexie.org/docs/DexieErrors/DexieError
|
|
795
794
|
*
|
|
796
795
|
*/
|
|
797
796
|
export interface DexieError extends Error {
|
|
@@ -805,7 +804,7 @@ export interface DexieError extends Error {
|
|
|
805
804
|
* List of the names of auto-generated error classes that extends DexieError
|
|
806
805
|
* and shares the interface of DexieError.
|
|
807
806
|
*
|
|
808
|
-
* Each error should be documented at
|
|
807
|
+
* Each error should be documented at https://dexie.org/docs/DexieErrors/Dexie.<errname>
|
|
809
808
|
*
|
|
810
809
|
* The generic type DexieExceptionClasses is a map of full error name to
|
|
811
810
|
* error constructor. The DexieExceptionClasses is mixed in into Dexie,
|
|
@@ -825,64 +824,64 @@ export interface DexieError extends Error {
|
|
|
825
824
|
* }
|
|
826
825
|
*/
|
|
827
826
|
export type DexieErrors = {
|
|
828
|
-
//
|
|
827
|
+
// https://dexie.org/docs/DexieErrors/Dexie.OpenFailedError
|
|
829
828
|
OpenFailed: "OpenFailedError";
|
|
830
|
-
//
|
|
829
|
+
// https://dexie.org/docs/DexieErrors/Dexie.VersionChangeError
|
|
831
830
|
VersionChange: "VersionChangeError";
|
|
832
|
-
//
|
|
831
|
+
// https://dexie.org/docs/DexieErrors/Dexie.SchemaError
|
|
833
832
|
Schema: "SchemaError";
|
|
834
|
-
//
|
|
833
|
+
// https://dexie.org/docs/DexieErrors/Dexie.UpgradeError
|
|
835
834
|
Upgrade: "UpgradeError";
|
|
836
|
-
//
|
|
835
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidTableError
|
|
837
836
|
InvalidTable: "InvalidTableError";
|
|
838
|
-
//
|
|
837
|
+
// https://dexie.org/docs/DexieErrors/Dexie.MissingAPIError
|
|
839
838
|
MissingAPI: "MissingAPIError";
|
|
840
|
-
//
|
|
839
|
+
// https://dexie.org/docs/DexieErrors/Dexie.NoSuchDatabaseError
|
|
841
840
|
NoSuchDatabase: "NoSuchDatabaseError";
|
|
842
|
-
//
|
|
841
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidArgumentError
|
|
843
842
|
InvalidArgument: "InvalidArgumentError";
|
|
844
|
-
//
|
|
843
|
+
// https://dexie.org/docs/DexieErrors/Dexie.SubTransactionError
|
|
845
844
|
SubTransaction: "SubTransactionError";
|
|
846
|
-
//
|
|
845
|
+
// https://dexie.org/docs/DexieErrors/Dexie.UnsupportedError
|
|
847
846
|
Unsupported: "UnsupportedError";
|
|
848
|
-
//
|
|
847
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InternalError
|
|
849
848
|
Internal: "InternalError";
|
|
850
|
-
//
|
|
849
|
+
// https://dexie.org/docs/DexieErrors/Dexie.DatabaseClosedError
|
|
851
850
|
DatabaseClosed: "DatabaseClosedError";
|
|
852
|
-
//
|
|
851
|
+
// https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError
|
|
853
852
|
PrematureCommit: "PrematureCommitError";
|
|
854
|
-
//
|
|
853
|
+
// https://dexie.org/docs/DexieErrors/Dexie.ForeignAwaitError
|
|
855
854
|
ForeignAwait: "ForeignAwaitError";
|
|
856
|
-
//
|
|
855
|
+
// https://dexie.org/docs/DexieErrors/Dexie.UnknownError
|
|
857
856
|
Unknown: "UnknownError";
|
|
858
|
-
//
|
|
857
|
+
// https://dexie.org/docs/DexieErrors/Dexie.ConstraintError
|
|
859
858
|
Constraint: "ConstraintError";
|
|
860
|
-
//
|
|
859
|
+
// https://dexie.org/docs/DexieErrors/Dexie.DataError
|
|
861
860
|
Data: "DataError";
|
|
862
|
-
//
|
|
861
|
+
// https://dexie.org/docs/DexieErrors/Dexie.TransactionInactiveError
|
|
863
862
|
TransactionInactive: "TransactionInactiveError";
|
|
864
|
-
//
|
|
863
|
+
// https://dexie.org/docs/DexieErrors/Dexie.ReadOnlyError
|
|
865
864
|
ReadOnly: "ReadOnlyError";
|
|
866
|
-
//
|
|
865
|
+
// https://dexie.org/docs/DexieErrors/Dexie.VersionError
|
|
867
866
|
Version: "VersionError";
|
|
868
|
-
//
|
|
867
|
+
// https://dexie.org/docs/DexieErrors/Dexie.NotFoundError
|
|
869
868
|
NotFound: "NotFoundError";
|
|
870
|
-
//
|
|
869
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidStateError
|
|
871
870
|
InvalidState: "InvalidStateError";
|
|
872
|
-
//
|
|
871
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidAccessError
|
|
873
872
|
InvalidAccess: "InvalidAccessError";
|
|
874
|
-
//
|
|
873
|
+
// https://dexie.org/docs/DexieErrors/Dexie.AbortError
|
|
875
874
|
Abort: "AbortError";
|
|
876
|
-
//
|
|
875
|
+
// https://dexie.org/docs/DexieErrors/Dexie.TimeoutError
|
|
877
876
|
Timeout: "TimeoutError";
|
|
878
|
-
//
|
|
877
|
+
// https://dexie.org/docs/DexieErrors/Dexie.QuotaExceededError
|
|
879
878
|
QuotaExceeded: "QuotaExceededError";
|
|
880
|
-
//
|
|
879
|
+
// https://dexie.org/docs/DexieErrors/Dexie.DataCloneError
|
|
881
880
|
DataClone: "DataCloneError";
|
|
882
881
|
};
|
|
883
882
|
/** ModifyError
|
|
884
883
|
*
|
|
885
|
-
*
|
|
884
|
+
* https://dexie.org/docs/DexieErrors/Dexie.ModifyError
|
|
886
885
|
*/
|
|
887
886
|
export interface ModifyError extends DexieError {
|
|
888
887
|
failures: Array<any>;
|
|
@@ -891,7 +890,7 @@ export interface ModifyError extends DexieError {
|
|
|
891
890
|
}
|
|
892
891
|
/** BulkError
|
|
893
892
|
*
|
|
894
|
-
*
|
|
893
|
+
* https://dexie.org/docs/DexieErrors/Dexie.BulkError
|
|
895
894
|
*/
|
|
896
895
|
export interface BulkError extends DexieError {
|
|
897
896
|
failures: Error[];
|
|
@@ -926,9 +925,15 @@ export interface DexieDOMDependencies {
|
|
|
926
925
|
indexedDB: IDBFactory;
|
|
927
926
|
IDBKeyRange: typeof IDBKeyRange;
|
|
928
927
|
}
|
|
928
|
+
declare global {
|
|
929
|
+
interface SymbolConstructor {
|
|
930
|
+
readonly observable: symbol;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
929
933
|
export interface Observable<T = any> {
|
|
930
934
|
subscribe(onNext?: ((value: T) => void) | null, onError?: ((error: any) => void) | null, onComplete?: (() => void) | null): Subscription;
|
|
931
935
|
subscribe(observer?: Observer<T> | null): Subscription;
|
|
936
|
+
[Symbol.observable]: () => Observable<T>;
|
|
932
937
|
}
|
|
933
938
|
export interface Subscription {
|
|
934
939
|
unsubscribe(): void;
|