SQLite in Chrome

Hi,
I’m using SQLite (import {SQLite} from ‘ionic-native’:wink: and on Android device is it OK.
But I need test my application in Chrome browser and in SQLite doesn’t work there (Unable to open database ReferenceError: sqlitePlugin is not defined)
Is any tool or way how use SQLite on device and something else in browser and don’t create db queries for two different db systems? Because only solution on my mind is create condition and when I’m in browser work with other db system.

Thanks

You can use the presence of window.sqlitePlugin to determine whether you have SQLite, and if not, fall back to IndexedDB by opening your database with a line like:

window.openDatabase(_SQLITE_DB_NAME, '1.0', 'database', 5 * 1024 * 1024);

From that point out, none of the rest of your code should have to know or care what kind of database object it is dealing with - they have the same API.

1 Like

Thanks
And based your reply I found right now probably done solution: https://github.com/seand88/ionic2-sql-interface