SQLite with phonegap

0

I am trying to develop a multiplatform application based on Apache Cordova and Phonegap.

To start I'd like to have a local BD that is larger than 5MB, which is what offers phonegap and its localstorage. Therefore, I have tried to introduce the following plugin.

link

But it is not compatible with phonegab, I am looking for an alternative that allows to mount the application with phonegap, or another system to generate my multiplatform app using cordova.

Even with the use of this plugin and the debugge through VS2017 of the following code js

function onDeviceReady() {



    // Controlar la pausa de Cordova y reanudar eventos
    document.addEventListener('pause', onPause.bind(this), false);
    document.addEventListener('resume', onResume.bind(this), false);

    // TODO: Cordova se ha cargado. Haga aquí las inicializaciones que necesiten Cordova.
    var parentElement = document.getElementById('deviceready');


    db = window.sqlitePlugin.openDatabase({
        name: 'my.db',
        location: 'default',
    });


    db.transaction(function (tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS DemoTable (name, score)');
        tx.executeSql('INSERT INTO DemoTable VALUES (?,?)', ['Alice', 101]);
        tx.executeSql('INSERT INTO DemoTable VALUES (?,?)', ['Betty', 202]);
    }, function (error) {
        console.log('Transaction ERROR: ' + error.message);
    }, function () {
        console.log('Populated database OK');
    });

    db.transaction(function (tx) {
        tx.executeSql('SELECT count(*) AS mycount FROM DemoTable', [], function (tx, rs) {
            console.log('Record count (expected to be 2): ' + rs.rows.item(0).mycount);
        }, function (tx, error) {
            console.log('SELECT error: ' + error.message);
        });
    });


    //var listeningElement = parentElement.querySelector('.listening');
    //var receivedElement = parentElement.querySelector('.received');
    //listeningElement.setAttribute('style', 'display:none;');
    //receivedElement.setAttribute('style', 'display:block;');

};

The next output is obtained through the console of the VS2017

If it were not phonegap, I would be willing to develop it under another plugin.

Greetings

    
asked by jld 06.08.2018 в 08:45
source

0 answers