diff --git a/dist/CordovaNativeSqliteProvider.d.ts b/dist/CordovaNativeSqliteProvider.d.ts index e3c27c6..5004f35 100644 --- a/dist/CordovaNativeSqliteProvider.d.ts +++ b/dist/CordovaNativeSqliteProvider.d.ts @@ -10,7 +10,7 @@ import NoSqlProvider = require('./NoSqlProviderInterfaces'); import SqlProviderBase = require('./SqlProviderBase'); export declare class CordovaNativeSqliteProvider extends SqlProviderBase.SqlProviderBase { private _db; - open(dbName: string, schema: NoSqlProvider.DbSchema, wipeIfExists: boolean, verbose: boolean): SyncTasks.Promise; + open(dbName: string, schema: NoSqlProvider.DbSchema, wipeIfExists: boolean, verbose: boolean, plugin?: SqlitePlugin): SyncTasks.Promise; close(): SyncTasks.Promise; openTransaction(storeNames: string | string[], writeNeeded: boolean): SyncTasks.Promise; } diff --git a/dist/CordovaNativeSqliteProvider.js b/dist/CordovaNativeSqliteProvider.js index 0026b44..cc2def7 100644 --- a/dist/CordovaNativeSqliteProvider.js +++ b/dist/CordovaNativeSqliteProvider.js @@ -18,15 +18,16 @@ var CordovaNativeSqliteProvider = (function (_super) { function CordovaNativeSqliteProvider() { _super.apply(this, arguments); } - CordovaNativeSqliteProvider.prototype.open = function (dbName, schema, wipeIfExists, verbose) { + CordovaNativeSqliteProvider.prototype.open = function (dbName, schema, wipeIfExists, verbose, plugin) { + if (plugin === void 0) { plugin = window.sqlitePlugin; } _super.prototype.open.call(this, dbName, schema, wipeIfExists, verbose); - if (!window.sqlitePlugin || !window.sqlitePlugin.openDatabase) { + if (!plugin || !plugin.openDatabase) { return SyncTasks.Rejected('No support for native sqlite in this browser'); } if (typeof (navigator) !== 'undefined' && navigator.userAgent.indexOf('Mobile Crosswalk') !== -1) { return SyncTasks.Rejected('Android NativeSqlite is broken, skipping'); } - this._db = window.sqlitePlugin.openDatabase({ + this._db = plugin.openDatabase({ name: dbName + '.db', location: 2, androidDatabaseImplementation: 2, diff --git a/src/CordovaNativeSqliteProvider.ts b/src/CordovaNativeSqliteProvider.ts index 4a82219..7db5ba0 100644 --- a/src/CordovaNativeSqliteProvider.ts +++ b/src/CordovaNativeSqliteProvider.ts @@ -14,10 +14,11 @@ import SqlProviderBase = require('./SqlProviderBase'); // The DbProvider implementation for Native Sqlite on cordova export class CordovaNativeSqliteProvider extends SqlProviderBase.SqlProviderBase { private _db: SqliteDatabase; - open(dbName: string, schema: NoSqlProvider.DbSchema, wipeIfExists: boolean, verbose: boolean): SyncTasks.Promise { + open(dbName: string, schema: NoSqlProvider.DbSchema, wipeIfExists: boolean, verbose: boolean, + plugin: SqlitePlugin = window.sqlitePlugin): SyncTasks.Promise { super.open(dbName, schema, wipeIfExists, verbose); - if (!window.sqlitePlugin || !window.sqlitePlugin.openDatabase) { + if (!plugin || !plugin.openDatabase) { return SyncTasks.Rejected('No support for native sqlite in this browser'); } @@ -25,7 +26,7 @@ export class CordovaNativeSqliteProvider extends SqlProviderBase.SqlProviderBase return SyncTasks.Rejected('Android NativeSqlite is broken, skipping'); } - this._db = window.sqlitePlugin.openDatabase({ + this._db = plugin.openDatabase({ name: dbName + '.db', location: 2, androidDatabaseImplementation: 2,