Dexie Logo

    Dexie.BulkError

    Inheritance Hierarchy

    Description

    The method that may throw this error can perform multiple operations on a table. Therefore this error object will contain an array of the errors the occurred during the failed operations.

    Properties

    failuresArray of Error objects of all errors that have occurred
    failuresByPos (since 3.1.0-alpha.7)Object that maps each failing operation's position to an error

    Properties derived from Error

    message

    name

    Sample

    db.friends.bulkAdd([
        {id: "shouldBeUnique", name: "Foo", age: 99},
        {id: "shouldBeUnique", name: "Bar", age: 21}])
    .catch('BulkError', err => {
        err.failures.forEach(failure => {
            console.error (failure.message);
        });
        // If on dexie@>3.1.0-alpha.6:
        for (const [pos, error] of Object.entries(err.failuresByPos)) {
          console.error(`Operation ${pos} failed with ${error}`);
        }
    });
    
    Note: Catching the error means that the successful operations will be saved. If not catching the error, all operations will be reverted and if there is an ongoing transaction, it will be aborted.

    © 2014-2025 Awarica AB

    Made with love for great people.

    Read Terms & Conditions and Privacy Policy.

    We recently launched a new website! Missing something? Visit the old site. Your feedback is welcome!