yathit / ydn-db

Javascript database module for Indexeddb, Web SQL and localStorage storage mechanisms supporting version migration, advanced query, SQL and transaction.
Apache License 2.0
503 stars 41 forks source link

getLastVersion returns NAN #32

Closed inluxc closed 9 years ago

inluxc commented 10 years ago

getLastVersion returns NAN console.log(event.getOldVersion());

        db.addEventListener('ready', function(event) {
            var is_updated = event.getVersion() != event.getOldVersion();
            if (is_updated) {
                console.log('database connected with new schema');
                console.log(event.getOldVersion());
                migrations.run(event.getOldVersion());
            } else if (isNaN(event.getOldVersion()))  {
                console.log('new database created');
            } else {
                console.log('existing database connected');
            }
            app.db = db;
            app.DBconnected = true;
        });
yathit commented 10 years ago

When there is no existing database, last version is NAN.

inluxc commented 10 years ago

Sorry i close by mistake, I have a DB and a version associated.

yathit commented 10 years ago

Could you make runnable script in jsfiddle?

Please also run unit test http://dev.yathit.com/test/test_events.html It test getOldVersion()