lib/sklad.js
function getObjStoresMeta(db, objStoreNames) {
    const dbMeta = objStoresMeta.get(db.name);
    const promises = [];

    objStoreNames.forEach(objStoreName => {
        if (dbMeta.has(objStoreName)) {
            return;
        }

        const promise = new Promise(resolve => {
            const transaction = db.transaction([objStoreName], TRANSACTION_READWRITE);
            transaction.oncomplete = resolve;
            transaction.onabort = resolve;

            const objStore = transaction.objectStore(objStoreName);

            if (objStore.autoIncrement !== undefined) {
                dbMeta.set(objStoreName, {
                    autoIncrement: objStore.autoIncrement,
                    keyPath: objStore.keyPath
                });

                return;
            }

            let autoIncrement;

            if (objStore.keyPath !== null) {
                // if key path is defined it's possible to insert only objects
                // but if key generator (autoIncrement) is not defined the inserted objects
                // must contain field(s) described in keyPath value otherwise IDBObjectStore.add op fails
                // so if we run ODBObjectStore.add with an empty object and it fails, this means that
                // autoIncrement property was false. Otherwise - true
                // if key path is array autoIncrement property can't be true
                if (Array.isArray(objStore.keyPath)) {
                    autoIncrement = false;
                } else {
                    try {
                        objStore.add({});
                        autoIncrement = true;
                    } catch (ex) {
                        autoIncrement = false;
                    }
                }
            } else {
                // if key path is not defined it's possible to insert any kind of data
                // but if key generator (autoIncrement) is not defined you should set it explicitly
                // so if we run ODBObjectStore.add with one argument and it fails, this means that
                // autoIncrement property was false. Otherwise - true
                try {
                    objStore.add('some value');
                    autoIncrement = true;
                } catch (ex) {
                    autoIncrement = false;
                }
            }

            // save meta properties
            dbMeta.set(objStoreName, {
                autoIncrement: autoIncrement,
                keyPath: objStore.keyPath
            });

            // and abort transaction so that new record is forgotten
            transaction.abort();
        });

        promises.push(promise);
    });

    return Promise.all(promises);
}
function getObjStoresMeta(db, objStoreNames) {
    const dbMeta = objStoresMeta.get(db.name);
    const promises = [];

    objStoreNames.forEach(objStoreName => {
        if (dbMeta.has(objStoreName)) {
            return;
        }

        const promise = new Promise(resolve => {
            const transaction = db.transaction([objStoreName], TRANSACTION_READWRITE);
            transaction.oncomplete = resolve;
            transaction.onabort = resolve;

            const objStore = transaction.objectStore(objStoreName);

            if (objStore.autoIncrement !== undefined) {
                dbMeta.set(objStoreName, {
                    autoIncrement: objStore.autoIncrement,
                    keyPath: objStore.keyPath
                });

                return;
            }

            let autoIncrement;

            if (objStore.keyPath !== null) {
                // if key path is defined it's possible to insert only objects
                // but if key generator (autoIncrement) is not defined the inserted objects
                // must contain field(s) described in keyPath value otherwise IDBObjectStore.add op fails
                // so if we run ODBObjectStore.add with an empty object and it fails, this means that
                // autoIncrement property was false. Otherwise - true
                // if key path is array autoIncrement property can't be true
                if (Array.isArray(objStore.keyPath)) {
                    autoIncrement = false;
                } else {
                    try {
                        objStore.add({});
                        autoIncrement = true;
                    } catch (ex) {
                        autoIncrement = false;
                    }
                }
            } else {
                // if key path is not defined it's possible to insert any kind of data
                // but if key generator (autoIncrement) is not defined you should set it explicitly
                // so if we run ODBObjectStore.add with one argument and it fails, this means that
                // autoIncrement property was false. Otherwise - true
                try {
                    objStore.add('some value');
                    autoIncrement = true;
                } catch (ex) {
                    autoIncrement = false;
                }
            }

            // save meta properties
            dbMeta.set(objStoreName, {
                autoIncrement: autoIncrement,
                keyPath: objStore.keyPath
            });

            // and abort transaction so that new record is forgotten
            transaction.abort();
        });

        promises.push(promise);
    });

    return Promise.all(promises);
}
function getObjStoresMeta ( db , objStoreNames ) { const dbMeta = objStoresMeta . get ( db . name ) ; const promises = [ ] ; objStoreNames . forEach ( objStoreName => { if ( dbMeta . has ( objStoreName ) ) { return ; } const promise = new Promise ( resolve => { const transaction = db . transaction ( [ objStoreName ] , TRANSACTION_READWRITE ) ; transaction . oncomplete = resolve ; transaction . onabort = resolve ; const objStore = transaction . objectStore ( objStoreName ) ; if ( objStore . autoIncrement !== undefined ) { dbMeta . set ( objStoreName , { autoIncrement : objStore . autoIncrement , keyPath : objStore . keyPath } ) ; return ; } let autoIncrement ; if ( objStore . keyPath !== null ) { // if key path is defined it's possible to insert only objects // but if key generator (autoIncrement) is not defined the inserted objects // must contain field(s) described in keyPath value otherwise IDBObjectStore.add op fails // so if we run ODBObjectStore.add with an empty object and it fails, this means that // autoIncrement property was false. Otherwise - true // if key path is array autoIncrement property can't be true if ( Array . isArray ( objStore . keyPath ) ) { autoIncrement = false ; } else { try { objStore . add ( { } ) ; autoIncrement = true ; } catch ( ex ) { autoIncrement = false ; } } } else { // if key path is not defined it's possible to insert any kind of data // but if key generator (autoIncrement) is not defined you should set it explicitly // so if we run ODBObjectStore.add with one argument and it fails, this means that // autoIncrement property was false. Otherwise - true try { objStore . add ( 'some value' ) ; autoIncrement = true ; } catch ( ex ) { autoIncrement = false ; } } // save meta properties dbMeta . set ( objStoreName , { autoIncrement : autoIncrement , keyPath : objStore . keyPath } ) ; // and abort transaction so that new record is forgotten transaction . abort ( ) ; } ) ; promises . push ( promise ) ; } ) ; return Promise . all ( promises ) ; }
autoIncrement is broken in IE family. Run this transaction to get its value
on every object store

@param {IDBDatabase} db
@param {Array<String>} objStoreNames
@return {Promise}

@see http://stackoverflow.com/questions/35682165/indexeddb-in-ie11-edge-why-is-objstore-autoincrement-undefined
@see https://connect.microsoft.com/IE/Feedback/Details/772726
autoIncrement is broken in IE family . Run this transaction to get its value on every object store