lib/livedata/WebSqlStore.js
function openDatabase(options) {
    var db;
    var sqlitePlugin = 'sqlitePlugin';
    if (global[sqlitePlugin]) {
        // device implementation
        options = _.clone(options);
        if (!options.key) {
            if (options.security) {
                options.key = options.security;
                delete options.security;
            }
            else if (options.credentials) {
                options.key = cipher.hashJsonSync(options.credentials, 'sha256').toString('hex');
                delete options.credentials;
            }
        }
        if (!options.location) {
            options.location = 2;
        }
        db = global[sqlitePlugin].openDatabase(options);
    }
    else if (global['openDatabase']) {
        // native implementation
        db = global['openDatabase'](options.name, options.version || '', options.description || '', options.size || 1024 * 1024);
    }
    else if (process && !process['browser']) {
        // node.js implementation
        var websql = void 0;
        try {
            websql = require('websql');
        }
        catch (error) {
            diag.debug.warn(error);
        }
        if (websql) {
            db = websql(options.name, options.version || '', options.description || '', options.size || 1024 * 1024);
        }
    }
    if (!db) {
        // when this is reached no supported implementation is present
        throw new Error('WebSQL implementation is not available');
    }
    return db;
}
function openDatabase(options) {
    var db;
    var sqlitePlugin = 'sqlitePlugin';
    if (global[sqlitePlugin]) {
        // device implementation
        options = _.clone(options);
        if (!options.key) {
            if (options.security) {
                options.key = options.security;
                delete options.security;
            }
            else if (options.credentials) {
                options.key = cipher.hashJsonSync(options.credentials, 'sha256').toString('hex');
                delete options.credentials;
            }
        }
        if (!options.location) {
            options.location = 2;
        }
        db = global[sqlitePlugin].openDatabase(options);
    }
    else if (global['openDatabase']) {
        // native implementation
        db = global['openDatabase'](options.name, options.version || '', options.description || '', options.size || 1024 * 1024);
    }
    else if (process && !process['browser']) {
        // node.js implementation
        var websql = void 0;
        try {
            websql = require('websql');
        }
        catch (error) {
            diag.debug.warn(error);
        }
        if (websql) {
            db = websql(options.name, options.version || '', options.description || '', options.size || 1024 * 1024);
        }
    }
    if (!db) {
        // when this is reached no supported implementation is present
        throw new Error('WebSQL implementation is not available');
    }
    return db;
}
function openDatabase ( options ) { var db ; var sqlitePlugin = 'sqlitePlugin' ; if ( global [ sqlitePlugin ] ) { // device implementation options = _ . clone ( options ) ; if ( ! options . key ) { if ( options . security ) { options . key = options . security ; delete options . security ; } else if ( options . credentials ) { options . key = cipher . hashJsonSync ( options . credentials , 'sha256' ) . toString ( 'hex' ) ; delete options . credentials ; } } if ( ! options . location ) { options . location = 2 ; } db = global [ sqlitePlugin ] . openDatabase ( options ) ; } else if ( global [ 'openDatabase' ] ) { // native implementation db = global [ 'openDatabase' ] ( options . name , options . version || '' , options . description || '' , options . size || 1024 * 1024 ) ; } else if ( process && ! process [ 'browser' ] ) { // node.js implementation var websql = void 0 ; try { websql = require ( 'websql' ) ; } catch ( error ) { diag . debug . warn ( error ) ; } if ( websql ) { db = websql ( options . name , options . version || '' , options . description || '' , options . size || 1024 * 1024 ) ; } } if ( ! db ) { // when this is reached no supported implementation is present throw new Error ( 'WebSQL implementation is not available' ) ; } return db ; }
openDatabase of browser or via require websql.

@internal Not public API, exported for testing purposes only!
openDatabase of browser or via require websql .