dexie 3.2.0-rc.3 → 3.2.1
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 +35 -35
- package/dist/dexie.js +23 -5
- 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 +23 -5
- 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 +23 -5
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.mjs +7 -0
- package/import-wrapper.mjs +7 -0
- package/package.json +27 -2
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,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 3.2.
|
|
7
|
+
* Version 3.2.1, Wed Feb 16 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
|
*/
|
|
@@ -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[];
|
|
@@ -790,7 +790,7 @@ export interface Dexie extends Database {
|
|
|
790
790
|
* Common base class for all errors originating from Dexie.js except TypeError,
|
|
791
791
|
* SyntaxError and RangeError.
|
|
792
792
|
*
|
|
793
|
-
*
|
|
793
|
+
* https://dexie.org/docs/DexieErrors/DexieError
|
|
794
794
|
*
|
|
795
795
|
*/
|
|
796
796
|
export interface DexieError extends Error {
|
|
@@ -804,7 +804,7 @@ export interface DexieError extends Error {
|
|
|
804
804
|
* List of the names of auto-generated error classes that extends DexieError
|
|
805
805
|
* and shares the interface of DexieError.
|
|
806
806
|
*
|
|
807
|
-
* Each error should be documented at
|
|
807
|
+
* Each error should be documented at https://dexie.org/docs/DexieErrors/Dexie.<errname>
|
|
808
808
|
*
|
|
809
809
|
* The generic type DexieExceptionClasses is a map of full error name to
|
|
810
810
|
* error constructor. The DexieExceptionClasses is mixed in into Dexie,
|
|
@@ -824,64 +824,64 @@ export interface DexieError extends Error {
|
|
|
824
824
|
* }
|
|
825
825
|
*/
|
|
826
826
|
export type DexieErrors = {
|
|
827
|
-
//
|
|
827
|
+
// https://dexie.org/docs/DexieErrors/Dexie.OpenFailedError
|
|
828
828
|
OpenFailed: "OpenFailedError";
|
|
829
|
-
//
|
|
829
|
+
// https://dexie.org/docs/DexieErrors/Dexie.VersionChangeError
|
|
830
830
|
VersionChange: "VersionChangeError";
|
|
831
|
-
//
|
|
831
|
+
// https://dexie.org/docs/DexieErrors/Dexie.SchemaError
|
|
832
832
|
Schema: "SchemaError";
|
|
833
|
-
//
|
|
833
|
+
// https://dexie.org/docs/DexieErrors/Dexie.UpgradeError
|
|
834
834
|
Upgrade: "UpgradeError";
|
|
835
|
-
//
|
|
835
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidTableError
|
|
836
836
|
InvalidTable: "InvalidTableError";
|
|
837
|
-
//
|
|
837
|
+
// https://dexie.org/docs/DexieErrors/Dexie.MissingAPIError
|
|
838
838
|
MissingAPI: "MissingAPIError";
|
|
839
|
-
//
|
|
839
|
+
// https://dexie.org/docs/DexieErrors/Dexie.NoSuchDatabaseError
|
|
840
840
|
NoSuchDatabase: "NoSuchDatabaseError";
|
|
841
|
-
//
|
|
841
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidArgumentError
|
|
842
842
|
InvalidArgument: "InvalidArgumentError";
|
|
843
|
-
//
|
|
843
|
+
// https://dexie.org/docs/DexieErrors/Dexie.SubTransactionError
|
|
844
844
|
SubTransaction: "SubTransactionError";
|
|
845
|
-
//
|
|
845
|
+
// https://dexie.org/docs/DexieErrors/Dexie.UnsupportedError
|
|
846
846
|
Unsupported: "UnsupportedError";
|
|
847
|
-
//
|
|
847
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InternalError
|
|
848
848
|
Internal: "InternalError";
|
|
849
|
-
//
|
|
849
|
+
// https://dexie.org/docs/DexieErrors/Dexie.DatabaseClosedError
|
|
850
850
|
DatabaseClosed: "DatabaseClosedError";
|
|
851
|
-
//
|
|
851
|
+
// https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError
|
|
852
852
|
PrematureCommit: "PrematureCommitError";
|
|
853
|
-
//
|
|
853
|
+
// https://dexie.org/docs/DexieErrors/Dexie.ForeignAwaitError
|
|
854
854
|
ForeignAwait: "ForeignAwaitError";
|
|
855
|
-
//
|
|
855
|
+
// https://dexie.org/docs/DexieErrors/Dexie.UnknownError
|
|
856
856
|
Unknown: "UnknownError";
|
|
857
|
-
//
|
|
857
|
+
// https://dexie.org/docs/DexieErrors/Dexie.ConstraintError
|
|
858
858
|
Constraint: "ConstraintError";
|
|
859
|
-
//
|
|
859
|
+
// https://dexie.org/docs/DexieErrors/Dexie.DataError
|
|
860
860
|
Data: "DataError";
|
|
861
|
-
//
|
|
861
|
+
// https://dexie.org/docs/DexieErrors/Dexie.TransactionInactiveError
|
|
862
862
|
TransactionInactive: "TransactionInactiveError";
|
|
863
|
-
//
|
|
863
|
+
// https://dexie.org/docs/DexieErrors/Dexie.ReadOnlyError
|
|
864
864
|
ReadOnly: "ReadOnlyError";
|
|
865
|
-
//
|
|
865
|
+
// https://dexie.org/docs/DexieErrors/Dexie.VersionError
|
|
866
866
|
Version: "VersionError";
|
|
867
|
-
//
|
|
867
|
+
// https://dexie.org/docs/DexieErrors/Dexie.NotFoundError
|
|
868
868
|
NotFound: "NotFoundError";
|
|
869
|
-
//
|
|
869
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidStateError
|
|
870
870
|
InvalidState: "InvalidStateError";
|
|
871
|
-
//
|
|
871
|
+
// https://dexie.org/docs/DexieErrors/Dexie.InvalidAccessError
|
|
872
872
|
InvalidAccess: "InvalidAccessError";
|
|
873
|
-
//
|
|
873
|
+
// https://dexie.org/docs/DexieErrors/Dexie.AbortError
|
|
874
874
|
Abort: "AbortError";
|
|
875
|
-
//
|
|
875
|
+
// https://dexie.org/docs/DexieErrors/Dexie.TimeoutError
|
|
876
876
|
Timeout: "TimeoutError";
|
|
877
|
-
//
|
|
877
|
+
// https://dexie.org/docs/DexieErrors/Dexie.QuotaExceededError
|
|
878
878
|
QuotaExceeded: "QuotaExceededError";
|
|
879
|
-
//
|
|
879
|
+
// https://dexie.org/docs/DexieErrors/Dexie.DataCloneError
|
|
880
880
|
DataClone: "DataCloneError";
|
|
881
881
|
};
|
|
882
882
|
/** ModifyError
|
|
883
883
|
*
|
|
884
|
-
*
|
|
884
|
+
* https://dexie.org/docs/DexieErrors/Dexie.ModifyError
|
|
885
885
|
*/
|
|
886
886
|
export interface ModifyError extends DexieError {
|
|
887
887
|
failures: Array<any>;
|
|
@@ -890,7 +890,7 @@ export interface ModifyError extends DexieError {
|
|
|
890
890
|
}
|
|
891
891
|
/** BulkError
|
|
892
892
|
*
|
|
893
|
-
*
|
|
893
|
+
* https://dexie.org/docs/DexieErrors/Dexie.BulkError
|
|
894
894
|
*/
|
|
895
895
|
export interface BulkError extends DexieError {
|
|
896
896
|
failures: Error[];
|
package/dist/dexie.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 3.2.
|
|
7
|
+
* Version 3.2.1, Wed Feb 16 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
|
*/
|
|
@@ -1266,8 +1266,14 @@
|
|
|
1266
1266
|
var trans = db._createTransaction(mode, storeNames, db._dbSchema);
|
|
1267
1267
|
try {
|
|
1268
1268
|
trans.create();
|
|
1269
|
+
db._state.PR1398_maxLoop = 3;
|
|
1269
1270
|
}
|
|
1270
1271
|
catch (ex) {
|
|
1272
|
+
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
|
|
1273
|
+
console.warn('Dexie: Need to reopen db');
|
|
1274
|
+
db._close();
|
|
1275
|
+
return db.open().then(function () { return tempTransaction(db, mode, storeNames, fn); });
|
|
1276
|
+
}
|
|
1271
1277
|
return rejection(ex);
|
|
1272
1278
|
}
|
|
1273
1279
|
return trans._promise(mode, function (resolve, reject) {
|
|
@@ -1281,7 +1287,7 @@
|
|
|
1281
1287
|
}
|
|
1282
1288
|
}
|
|
1283
1289
|
|
|
1284
|
-
var DEXIE_VERSION = '3.2.
|
|
1290
|
+
var DEXIE_VERSION = '3.2.1';
|
|
1285
1291
|
var maxString = String.fromCharCode(65535);
|
|
1286
1292
|
var minKey = -Infinity;
|
|
1287
1293
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -3857,7 +3863,18 @@
|
|
|
3857
3863
|
trans.idbtrans = parentTransaction.idbtrans;
|
|
3858
3864
|
}
|
|
3859
3865
|
else {
|
|
3860
|
-
|
|
3866
|
+
try {
|
|
3867
|
+
trans.create();
|
|
3868
|
+
db._state.PR1398_maxLoop = 3;
|
|
3869
|
+
}
|
|
3870
|
+
catch (ex) {
|
|
3871
|
+
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
|
|
3872
|
+
console.warn('Dexie: Need to reopen db');
|
|
3873
|
+
db._close();
|
|
3874
|
+
return db.open().then(function () { return enterTransactionScope(db, mode, storeNames, null, scopeFunc); });
|
|
3875
|
+
}
|
|
3876
|
+
return rejection(ex);
|
|
3877
|
+
}
|
|
3861
3878
|
}
|
|
3862
3879
|
var scopeFuncIsAsync = isAsyncFunction(scopeFunc);
|
|
3863
3880
|
if (scopeFuncIsAsync) {
|
|
@@ -4589,7 +4606,8 @@
|
|
|
4589
4606
|
dbReadyPromise: null,
|
|
4590
4607
|
cancelOpen: nop,
|
|
4591
4608
|
openCanceller: null,
|
|
4592
|
-
autoSchema: true
|
|
4609
|
+
autoSchema: true,
|
|
4610
|
+
PR1398_maxLoop: 3
|
|
4593
4611
|
};
|
|
4594
4612
|
state.dbReadyPromise = new DexiePromise(function (resolve) {
|
|
4595
4613
|
state.dbReadyResolve = resolve;
|