-
-
Notifications
You must be signed in to change notification settings - Fork 641
Dexie.IncompatiblePromiseError
David Fahlander edited this page Apr 5, 2016
·
34 revisions
-
Error
-
Dexie.DexieError
- Dexie.IncompatiblePromiseError
-
Dexie.DexieError
Happens when returning an incompatible Promise from a transaction scope.
Dexie.Promises are compatible with other Promises, but in transaction scopes you must use Dexie.Promise only. Outside transaction scopes, you are free to mix with other promises. The reason is that Dexie's transaction scope needs to do the following:
- Make sure indexedDB transactions aren't committed too early
- Keep track of currently ongoing transaction for the particular scope.
- Detect whether a promise was uncaught and if so, abort the transaction.
db.transaction ('rw', db.friends, function() {
// Always use Dexie.Promise in the scope:
return Dexie.Promise.all ([
db.friends.put({name: "Foo"}),
db.friends.put({name: "Bar"})
]);
});
function putFriends() {
let Promise = Dexie.Promise; // Make async use Dexie.Promise!
return db.transaction('rw', db.friends, async () => {
await db.friends.put({name: "Foo"});
await db.friends.put({name: "Bar"});
});
});
...or:
import Dexie from 'dexie';
let Promise = Dexie.Promise;
function putFriends() {
return db.transaction('rw', db.friends, async () => {
await db.friends.put({name: "Foo"});
await db.friends.put({name: "Bar"});
});
});
Dexie.js - minimalistic and bullet proof indexedDB library