How to use the idb.openDb function in idb

To help you get started, we’ve selected a few idb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gadicc / gongo / gongo-client / src / gongo.js View on Github external
async idbOpen() {
    log.debug('Opening IDB "gongo" database');
    this.idbIsOpen = true;

    // idbDbVersion is (purposefully) undefined for initial open
    this.idbPromise = openDb('gongo', this.idbDbVersion, upgradeDB => {
      log.info('Upgrading IDB "gongo" database v' + this.idbDbVersion);

      for (let name of upgradeDB._db.objectStoreNames)
        if (!this.collections.has(name))
          upgradeDB.deleteObjectStore(name);

      for (let [name] of this.collections)
        if (!upgradeDB._db.objectStoreNames.contains(name))
          upgradeDB.createObjectStore(name);
    });

    this.idbPromise.catch(e => {
      console.log(e.message);
      throw e;
    })
github sikidamjanovic / cowrite / node_modules / @firebase / installations / dist / index.esm.js View on Github external
function getDbPromise() {
    if (!dbPromise) {
        dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDB) {
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch (upgradeDB.oldVersion) {
                case 0:
                    upgradeDB.createObjectStore(OBJECT_STORE_NAME);
            }
        });
    }
    return dbPromise;
}
/** Assigns or overwrites the record for the given key with the given value. */
github maierj / fastlane-action / node_modules / @firebase / installations / dist / index.cjs.js View on Github external
function getDbPromise() {
    if (!dbPromise) {
        dbPromise = idb.openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDB) {
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch (upgradeDB.oldVersion) {
                case 0:
                    upgradeDB.createObjectStore(OBJECT_STORE_NAME);
            }
        });
    }
    return dbPromise;
}
/** Assigns or overwrites the record for the given key with the given value. */
github maierj / fastlane-action / node_modules / @firebase / installations / dist / index.esm2017.js View on Github external
function getDbPromise() {
    if (!dbPromise) {
        dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, upgradeDB => {
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch (upgradeDB.oldVersion) {
                case 0:
                    upgradeDB.createObjectStore(OBJECT_STORE_NAME);
            }
        });
    }
    return dbPromise;
}
/** Assigns or overwrites the record for the given key with the given value. */
github maierj / fastlane-action / node_modules / @firebase / installations / dist / index.esm.js View on Github external
function getDbPromise() {
    if (!dbPromise) {
        dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDB) {
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch (upgradeDB.oldVersion) {
                case 0:
                    upgradeDB.createObjectStore(OBJECT_STORE_NAME);
            }
        });
    }
    return dbPromise;
}
/** Assigns or overwrites the record for the given key with the given value. */
github sikidamjanovic / cowrite / node_modules / @firebase / installations / dist / index.esm2017.js View on Github external
function getDbPromise() {
    if (!dbPromise) {
        dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, upgradeDB => {
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch (upgradeDB.oldVersion) {
                case 0:
                    upgradeDB.createObjectStore(OBJECT_STORE_NAME);
            }
        });
    }
    return dbPromise;
}
/** Assigns or overwrites the record for the given key with the given value. */
github sikidamjanovic / cowrite / node_modules / @firebase / installations / dist / index.cjs.js View on Github external
function getDbPromise() {
    if (!dbPromise) {
        dbPromise = idb.openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDB) {
            // We don't use 'break' in this switch statement, the fall-through
            // behavior is what we want, because if there are multiple versions between
            // the old version and the current version, we want ALL the migrations
            // that correspond to those versions to run, not only the last one.
            // eslint-disable-next-line default-case
            switch (upgradeDB.oldVersion) {
                case 0:
                    upgradeDB.createObjectStore(OBJECT_STORE_NAME);
            }
        });
    }
    return dbPromise;
}
/** Assigns or overwrites the record for the given key with the given value. */
github rthaut / deviantART-Filter / src / helpers / IndexedDatabase.class.js View on Github external
constructor(databaseName, storeName, version, upgradeCallback) {
            this._storeName = storeName;

            this.openDB = openDB(databaseName, version, upgradeCallback);
        }
github trys / JournalBook / src / components / app.js View on Github external
async componentDidMount() {
    try {
      const version = 4;
      const dbPromise = openDb('entries-store', version, udb => {
        switch (udb.oldVersion) {
          case 0:
            udb.createObjectStore('questions');
          case 1:
            udb.createObjectStore('entries');
          case 2:
            udb.createObjectStore('highlights');
          case 3:
            udb.createObjectStore('settings', {
              theme: localStorage.getItem('journalbook_theme') || '',
              animation: window.matchMedia('(prefers-reduced-motion: reduce)')
                .matches
                ? 'off'
                : '',
            });
        }

idb

A small wrapper that makes IndexedDB usable

ISC
Latest version published 6 months ago

Package Health Score

83 / 100
Full package analysis