src/store/indexeddb-local-backend.js
function() {
        if (!this._disconnected) {
            console.log(
                `LocalIndexedDBStoreBackend.connect: already connected or connecting`,
            );
            return Promise.resolve();
        }

        this._disconnected = false;

        console.log(
            `LocalIndexedDBStoreBackend.connect: connecting...`,
        );
        const req = this.indexedDB.open(this._dbName, VERSION);
        req.onupgradeneeded = (ev) => {
            const db = ev.target.result;
            const oldVersion = ev.oldVersion;
            console.log(
                `LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`,
            );
            if (oldVersion < 1) { // The database did not previously exist.
                this._isNewlyCreated = true;
                createDatabase(db);
            }
            if (oldVersion < 2) {
                upgradeSchemaV2(db);
            }
            if (oldVersion < 3) {
                upgradeSchemaV3(db);
            }
            // Expand as needed.
        };

        req.onblocked = () => {
            console.log(
                `can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`,
            );
        };

        console.log(
            `LocalIndexedDBStoreBackend.connect: awaiting connection...`,
        );
        return reqAsEventPromise(req).then((ev) => {
            console.log(
                `LocalIndexedDBStoreBackend.connect: connected`,
            );
            this.db = ev.target.result;

            // add a poorly-named listener for when deleteDatabase is called
            // so we can close our db connections.
            this.db.onversionchange = () => {
                this.db.close();
            };

            return this._init();
        });
    }
function() {
        if (!this._disconnected) {
            console.log(
                `LocalIndexedDBStoreBackend.connect: already connected or connecting`,
            );
            return Promise.resolve();
        }

        this._disconnected = false;

        console.log(
            `LocalIndexedDBStoreBackend.connect: connecting...`,
        );
        const req = this.indexedDB.open(this._dbName, VERSION);
        req.onupgradeneeded = (ev) => {
            const db = ev.target.result;
            const oldVersion = ev.oldVersion;
            console.log(
                `LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`,
            );
            if (oldVersion < 1) { // The database did not previously exist.
                this._isNewlyCreated = true;
                createDatabase(db);
            }
            if (oldVersion < 2) {
                upgradeSchemaV2(db);
            }
            if (oldVersion < 3) {
                upgradeSchemaV3(db);
            }
            // Expand as needed.
        };

        req.onblocked = () => {
            console.log(
                `can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`,
            );
        };

        console.log(
            `LocalIndexedDBStoreBackend.connect: awaiting connection...`,
        );
        return reqAsEventPromise(req).then((ev) => {
            console.log(
                `LocalIndexedDBStoreBackend.connect: connected`,
            );
            this.db = ev.target.result;

            // add a poorly-named listener for when deleteDatabase is called
            // so we can close our db connections.
            this.db.onversionchange = () => {
                this.db.close();
            };

            return this._init();
        });
    }
function ( ) { if ( ! this . _disconnected ) { console . log ( ` ` , ) ; return Promise . resolve ( ) ; } this . _disconnected = false ; console . log ( ` ` , ) ; const req = this . indexedDB . open ( this . _dbName , VERSION ) ; req . onupgradeneeded = ( ev ) => { const db = ev . target . result ; const oldVersion = ev . oldVersion ; console . log ( ` ${ oldVersion } ` , ) ; if ( oldVersion < 1 ) { // The database did not previously exist. this . _isNewlyCreated = true ; createDatabase ( db ) ; } if ( oldVersion < 2 ) { upgradeSchemaV2 ( db ) ; } if ( oldVersion < 3 ) { upgradeSchemaV3 ( db ) ; } // Expand as needed. } ; req . onblocked = ( ) => { console . log ( ` ` , ) ; } ; console . log ( ` ` , ) ; return reqAsEventPromise ( req ) . then ( ( ev ) => { console . log ( ` ` , ) ; this . db = ev . target . result ; // add a poorly-named listener for when deleteDatabase is called // so we can close our db connections. this . db . onversionchange = ( ) => { this . db . close ( ) ; } ; return this . _init ( ) ; } ) ; }
Attempt to connect to the database. This can fail if the user does not
grant permission.
@return {Promise} Resolves if successfully connected.
Attempt to connect to the database . This can fail if the user does not grant permission .