lib/sklad.js
function checkSavedData(dbName, objStore, data) {
    const keyValueContainer = Object.prototype.isPrototypeOf.call(skladKeyValueContainer, data);
    const value = keyValueContainer ? data.value : data;
    const objStoreMeta = objStoresMeta.get(dbName).get(objStore.name);
    let key = keyValueContainer ? data.key : undefined;

    const keyPath = objStore.keyPath || objStoreMeta.keyPath;
    const autoIncrement = objStore.autoIncrement || objStoreMeta.autoIncrement;

    if (keyPath === null) {
        if (!autoIncrement && key === undefined) {
            key = uuid();
        }
    } else {
        if (typeof data !== 'object') {
            return false;
        }

        // TODO: support dot-separated and array keyPaths
        if (!autoIncrement && data[keyPath] === undefined) {
            data[keyPath] = uuid();
        }
    }

    return key ? [value, key] : [value];
}
function checkSavedData(dbName, objStore, data) {
    const keyValueContainer = Object.prototype.isPrototypeOf.call(skladKeyValueContainer, data);
    const value = keyValueContainer ? data.value : data;
    const objStoreMeta = objStoresMeta.get(dbName).get(objStore.name);
    let key = keyValueContainer ? data.key : undefined;

    const keyPath = objStore.keyPath || objStoreMeta.keyPath;
    const autoIncrement = objStore.autoIncrement || objStoreMeta.autoIncrement;

    if (keyPath === null) {
        if (!autoIncrement && key === undefined) {
            key = uuid();
        }
    } else {
        if (typeof data !== 'object') {
            return false;
        }

        // TODO: support dot-separated and array keyPaths
        if (!autoIncrement && data[keyPath] === undefined) {
            data[keyPath] = uuid();
        }
    }

    return key ? [value, key] : [value];
}
function checkSavedData ( dbName , objStore , data ) { const keyValueContainer = Object . prototype . isPrototypeOf . call ( skladKeyValueContainer , data ) ; const value = keyValueContainer ? data . value : data ; const objStoreMeta = objStoresMeta . get ( dbName ) . get ( objStore . name ) ; let key = keyValueContainer ? data . key : undefined ; const keyPath = objStore . keyPath || objStoreMeta . keyPath ; const autoIncrement = objStore . autoIncrement || objStoreMeta . autoIncrement ; if ( keyPath === null ) { if ( ! autoIncrement && key === undefined ) { key = uuid ( ) ; } } else { if ( typeof data !== 'object' ) { return false ; } // TODO: support dot-separated and array keyPaths if ( ! autoIncrement && data [ keyPath ] === undefined ) { data [ keyPath ] = uuid ( ) ; } } return key ? [ value , key ] : [ value ] ; }
Checks data before saving it in the object store
@return {Boolean} false if saved data type is incorrect, otherwise {Array} object store function arguments
Checks data before saving it in the object store