@capacitor-community/sqlite
Advanced tools
Comparing version 3.0.0-beta.9 to 3.0.0-beta.10
@@ -0,1 +1,11 @@ | ||
## 3.0.0-beta.10 (2021-04-14) | ||
### Bug Fixes | ||
- Fix Android app crashes when creating connection with wrong secret issue#105 | ||
- Fix reload of webview breaks connection handling #issue106 | ||
- Fix user provides a name that ends on ".db" #issue107 | ||
- Fix add an option to disable transactions #issue111 | ||
- add Supported SQLite Types in README.md #issue108 | ||
## 3.0.0-beta.9 (2021-04-02) | ||
@@ -88,2 +98,8 @@ | ||
## 2.9.16 (2021-04-13) REFACTOR | ||
### Bug Fixes | ||
- Fix Android app crashes when creating connection with wrong secret issue#105 | ||
## 2.9.15 (2021-04-01) REFACTOR | ||
@@ -90,0 +106,0 @@ |
@@ -174,3 +174,3 @@ declare module '@capacitor/core' { | ||
* @param options: capSQLitePathOptions | ||
* @returns Promise<capSQLiteResult> | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.5 | ||
@@ -182,6 +182,14 @@ */ | ||
* @param options: capSQLitePathOptions | ||
* @returns Promise<capSQLiteResult> | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.5 | ||
*/ | ||
deleteOldDatabases(options: capSQLitePathOptions): Promise<void>; | ||
/** | ||
* Check Connection Consistency JS <=> Native | ||
* if inconsistency all connections are removed | ||
* @param options: capAllConnectionsOptions | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
checkConnectionsConsistency(options: capAllConnectionsOptions): Promise<void>; | ||
} | ||
@@ -213,2 +221,9 @@ export interface capEchoOptions { | ||
} | ||
export interface capAllConnectionsOptions { | ||
/** | ||
* the dbName of all connections | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
dbNames?: string[]; | ||
} | ||
export interface capSQLiteOptions { | ||
@@ -229,2 +244,8 @@ /** | ||
statements?: string; | ||
/** | ||
* Enable / Disable transactions | ||
* default Enable (true) | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
transaction?: boolean; | ||
} | ||
@@ -240,2 +261,8 @@ export interface capSQLiteSetOptions { | ||
set?: capSQLiteSet[]; | ||
/** | ||
* Enable / Disable transactions | ||
* default Enable (true) | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
transaction?: boolean; | ||
} | ||
@@ -255,2 +282,8 @@ export interface capSQLiteRunOptions { | ||
values?: any[]; | ||
/** | ||
* Enable / Disable transactions | ||
* default Enable (true) | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
transaction?: boolean; | ||
} | ||
@@ -556,2 +589,10 @@ export interface capSQLiteQueryOptions { | ||
/** | ||
* Check the consistency between Js Connections | ||
* and Native Connections | ||
* if inconsistency all connections are removed | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
checkConnectionsConsistency(): Promise<void>; | ||
/** | ||
* Import a database From a JSON | ||
@@ -619,2 +660,3 @@ * @param jsonstring string | ||
closeAllConnections(): Promise<void>; | ||
checkConnectionsConsistency(): Promise<void>; | ||
importFromJson(jsonstring: string): Promise<capSQLiteChanges>; | ||
@@ -656,3 +698,3 @@ isJsonValid(jsonstring: string): Promise<capSQLiteResult>; | ||
*/ | ||
execute(statements: string): Promise<capSQLiteChanges>; | ||
execute(statements: string, transaction?: boolean): Promise<capSQLiteChanges>; | ||
/** | ||
@@ -673,3 +715,3 @@ * Execute SQLite DB Connection Query | ||
*/ | ||
run(statement: string, values?: any[]): Promise<capSQLiteChanges>; | ||
run(statement: string, values?: any[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
/** | ||
@@ -681,3 +723,3 @@ * Execute SQLite DB Connection Set | ||
*/ | ||
executeSet(set: capSQLiteSet[]): Promise<capSQLiteChanges>; | ||
executeSet(set: capSQLiteSet[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
/** | ||
@@ -745,6 +787,6 @@ * Check if a SQLite DB Connection exists | ||
close(): Promise<void>; | ||
execute(statements: string): Promise<capSQLiteChanges>; | ||
execute(statements: string, transaction?: boolean): Promise<capSQLiteChanges>; | ||
query(statement: string, values?: string[]): Promise<capSQLiteValues>; | ||
run(statement: string, values?: any[]): Promise<capSQLiteChanges>; | ||
executeSet(set: capSQLiteSet[]): Promise<capSQLiteChanges>; | ||
run(statement: string, values?: any[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
executeSet(set: capSQLiteSet[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
isExists(): Promise<capSQLiteResult>; | ||
@@ -751,0 +793,0 @@ isTable(table: string): Promise<capSQLiteResult>; |
@@ -38,2 +38,4 @@ /** | ||
}); | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
const conn = new SQLiteDBConnection(database, this.sqlite); | ||
@@ -49,2 +51,4 @@ this._connectionDict.set(database, conn); | ||
try { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
await this.sqlite.closeConnection({ database }); | ||
@@ -60,6 +64,11 @@ this._connectionDict.delete(database); | ||
const res = {}; | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
res.result = this._connectionDict.has(database); | ||
return res; | ||
console.log(`isConnection ${res.result}`); | ||
return Promise.resolve(res); | ||
} | ||
async retrieveConnection(database) { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
if (this._connectionDict.has(database)) { | ||
@@ -96,2 +105,16 @@ const conn = this._connectionDict.get(database); | ||
} | ||
async checkConnectionsConsistency() { | ||
try { | ||
const keys = [...this._connectionDict.keys()]; | ||
await this.sqlite.checkConnectionsConsistency({ | ||
dbNames: keys, | ||
}); | ||
return Promise.resolve(); | ||
} | ||
catch (err) { | ||
console.log(`checkConnectionsConsistency ${err}`); | ||
this._connectionDict = new Map(); | ||
return Promise.reject('You must redefined the connection'); | ||
} | ||
} | ||
async importFromJson(jsonstring) { | ||
@@ -125,2 +148,4 @@ try { | ||
async isDatabase(database) { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
try { | ||
@@ -195,7 +220,9 @@ const res = await this.sqlite.isDatabase({ database: database }); | ||
} | ||
async execute(statements) { | ||
async execute(statements, transaction) { | ||
try { | ||
const trans = transaction ? transaction : true; | ||
const res = await this.sqlite.execute({ | ||
database: this.dbName, | ||
statements: statements, | ||
transaction: trans, | ||
}); | ||
@@ -231,3 +258,4 @@ return Promise.resolve(res); | ||
} | ||
async run(statement, values) { | ||
async run(statement, values, transaction) { | ||
const trans = transaction ? transaction : true; | ||
let res; | ||
@@ -240,2 +268,3 @@ try { | ||
values: values, | ||
transaction: trans, | ||
}); | ||
@@ -248,2 +277,3 @@ } | ||
values: [], | ||
transaction: trans, | ||
}); | ||
@@ -257,3 +287,4 @@ } | ||
} | ||
async executeSet(set) { | ||
async executeSet(set, transaction) { | ||
const trans = transaction ? transaction : true; | ||
try { | ||
@@ -263,2 +294,3 @@ const res = await this.sqlite.executeSet({ | ||
set: set, | ||
transaction: trans, | ||
}); | ||
@@ -265,0 +297,0 @@ return Promise.resolve(res); |
import { WebPlugin } from '@capacitor/core'; | ||
import type { CapacitorSQLitePlugin, capEchoOptions, capSQLiteOptions, capSQLiteExecuteOptions, capSQLiteSetOptions, capSQLiteRunOptions, capSQLiteQueryOptions, capSQLiteImportOptions, capSQLiteExportOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteTableOptions, capSQLitePathOptions, capEchoResult, capSQLiteResult, capSQLiteChanges, capSQLiteValues, capSQLiteJson, capSQLiteSyncDate } from './definitions'; | ||
import type { CapacitorSQLitePlugin, capEchoOptions, capSQLiteOptions, capSQLiteExecuteOptions, capSQLiteSetOptions, capSQLiteRunOptions, capSQLiteQueryOptions, capSQLiteImportOptions, capSQLiteExportOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteTableOptions, capSQLitePathOptions, capEchoResult, capSQLiteResult, capSQLiteChanges, capSQLiteValues, capSQLiteJson, capSQLiteSyncDate, capAllConnectionsOptions } from './definitions'; | ||
export declare class CapacitorSQLiteWeb extends WebPlugin implements CapacitorSQLitePlugin { | ||
@@ -9,2 +9,3 @@ constructor(); | ||
closeConnection(options: capSQLiteOptions): Promise<void>; | ||
checkConnectionsConsistency(options: capAllConnectionsOptions): Promise<void>; | ||
close(options: capSQLiteOptions): Promise<void>; | ||
@@ -11,0 +12,0 @@ execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges>; |
@@ -25,2 +25,6 @@ import { WebPlugin } from '@capacitor/core'; | ||
} | ||
async checkConnectionsConsistency(options) { | ||
console.log('checkConsistency', options); | ||
throw this.unimplemented('Not implemented on web.'); | ||
} | ||
async close(options) { | ||
@@ -27,0 +31,0 @@ console.log('close', options); |
@@ -44,2 +44,4 @@ 'use strict'; | ||
}); | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
const conn = new SQLiteDBConnection(database, this.sqlite); | ||
@@ -55,2 +57,4 @@ this._connectionDict.set(database, conn); | ||
try { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
await this.sqlite.closeConnection({ database }); | ||
@@ -66,6 +70,11 @@ this._connectionDict.delete(database); | ||
const res = {}; | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
res.result = this._connectionDict.has(database); | ||
return res; | ||
console.log(`isConnection ${res.result}`); | ||
return Promise.resolve(res); | ||
} | ||
async retrieveConnection(database) { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
if (this._connectionDict.has(database)) { | ||
@@ -102,2 +111,16 @@ const conn = this._connectionDict.get(database); | ||
} | ||
async checkConnectionsConsistency() { | ||
try { | ||
const keys = [...this._connectionDict.keys()]; | ||
await this.sqlite.checkConnectionsConsistency({ | ||
dbNames: keys, | ||
}); | ||
return Promise.resolve(); | ||
} | ||
catch (err) { | ||
console.log(`checkConnectionsConsistency ${err}`); | ||
this._connectionDict = new Map(); | ||
return Promise.reject('You must redefined the connection'); | ||
} | ||
} | ||
async importFromJson(jsonstring) { | ||
@@ -131,2 +154,4 @@ try { | ||
async isDatabase(database) { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
try { | ||
@@ -201,7 +226,9 @@ const res = await this.sqlite.isDatabase({ database: database }); | ||
} | ||
async execute(statements) { | ||
async execute(statements, transaction) { | ||
try { | ||
const trans = transaction ? transaction : true; | ||
const res = await this.sqlite.execute({ | ||
database: this.dbName, | ||
statements: statements, | ||
transaction: trans, | ||
}); | ||
@@ -237,3 +264,4 @@ return Promise.resolve(res); | ||
} | ||
async run(statement, values) { | ||
async run(statement, values, transaction) { | ||
const trans = transaction ? transaction : true; | ||
let res; | ||
@@ -246,2 +274,3 @@ try { | ||
values: values, | ||
transaction: trans, | ||
}); | ||
@@ -254,2 +283,3 @@ } | ||
values: [], | ||
transaction: trans, | ||
}); | ||
@@ -263,3 +293,4 @@ } | ||
} | ||
async executeSet(set) { | ||
async executeSet(set, transaction) { | ||
const trans = transaction ? transaction : true; | ||
try { | ||
@@ -269,2 +300,3 @@ const res = await this.sqlite.executeSet({ | ||
set: set, | ||
transaction: trans, | ||
}); | ||
@@ -400,2 +432,6 @@ return Promise.resolve(res); | ||
} | ||
async checkConnectionsConsistency(options) { | ||
console.log('checkConsistency', options); | ||
throw this.unimplemented('Not implemented on web.'); | ||
} | ||
async close(options) { | ||
@@ -402,0 +438,0 @@ console.log('close', options); |
@@ -41,2 +41,4 @@ var capacitorCapacitorSQLite = (function (exports, core) { | ||
}); | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
const conn = new SQLiteDBConnection(database, this.sqlite); | ||
@@ -52,2 +54,4 @@ this._connectionDict.set(database, conn); | ||
try { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
await this.sqlite.closeConnection({ database }); | ||
@@ -63,6 +67,11 @@ this._connectionDict.delete(database); | ||
const res = {}; | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
res.result = this._connectionDict.has(database); | ||
return res; | ||
console.log(`isConnection ${res.result}`); | ||
return Promise.resolve(res); | ||
} | ||
async retrieveConnection(database) { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
if (this._connectionDict.has(database)) { | ||
@@ -99,2 +108,16 @@ const conn = this._connectionDict.get(database); | ||
} | ||
async checkConnectionsConsistency() { | ||
try { | ||
const keys = [...this._connectionDict.keys()]; | ||
await this.sqlite.checkConnectionsConsistency({ | ||
dbNames: keys, | ||
}); | ||
return Promise.resolve(); | ||
} | ||
catch (err) { | ||
console.log(`checkConnectionsConsistency ${err}`); | ||
this._connectionDict = new Map(); | ||
return Promise.reject('You must redefined the connection'); | ||
} | ||
} | ||
async importFromJson(jsonstring) { | ||
@@ -128,2 +151,4 @@ try { | ||
async isDatabase(database) { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
try { | ||
@@ -198,7 +223,9 @@ const res = await this.sqlite.isDatabase({ database: database }); | ||
} | ||
async execute(statements) { | ||
async execute(statements, transaction) { | ||
try { | ||
const trans = transaction ? transaction : true; | ||
const res = await this.sqlite.execute({ | ||
database: this.dbName, | ||
statements: statements, | ||
transaction: trans, | ||
}); | ||
@@ -234,3 +261,4 @@ return Promise.resolve(res); | ||
} | ||
async run(statement, values) { | ||
async run(statement, values, transaction) { | ||
const trans = transaction ? transaction : true; | ||
let res; | ||
@@ -243,2 +271,3 @@ try { | ||
values: values, | ||
transaction: trans, | ||
}); | ||
@@ -251,2 +280,3 @@ } | ||
values: [], | ||
transaction: trans, | ||
}); | ||
@@ -260,3 +290,4 @@ } | ||
} | ||
async executeSet(set) { | ||
async executeSet(set, transaction) { | ||
const trans = transaction ? transaction : true; | ||
try { | ||
@@ -266,2 +297,3 @@ const res = await this.sqlite.executeSet({ | ||
set: set, | ||
transaction: trans, | ||
}); | ||
@@ -397,2 +429,6 @@ return Promise.resolve(res); | ||
} | ||
async checkConnectionsConsistency(options) { | ||
console.log('checkConsistency', options); | ||
throw this.unimplemented('Not implemented on web.'); | ||
} | ||
async close(options) { | ||
@@ -399,0 +435,0 @@ console.log('close', options); |
import { WebPlugin } from '@capacitor/core'; | ||
import type { CapacitorSQLitePlugin, capConnectionOptions, capEchoOptions, capEchoResult, capSQLiteChanges, capSQLiteExecuteOptions, capSQLiteExportOptions, capSQLiteImportOptions, capSQLiteJson, capSQLiteOptions, capSQLiteQueryOptions, capSQLiteResult, capSQLiteRunOptions, capSQLiteSetOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteValues, capSQLiteSyncDate, capSQLiteTableOptions, capSQLitePathOptions } from './definitions'; | ||
import type { CapacitorSQLitePlugin, capConnectionOptions, capEchoOptions, capEchoResult, capSQLiteChanges, capSQLiteExecuteOptions, capSQLiteExportOptions, capSQLiteImportOptions, capSQLiteJson, capSQLiteOptions, capSQLiteQueryOptions, capSQLiteResult, capSQLiteRunOptions, capSQLiteSetOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteValues, capSQLiteSyncDate, capSQLiteTableOptions, capSQLitePathOptions, capAllConnectionsOptions } from './definitions'; | ||
export declare class CapacitorSQLiteElectronWeb extends WebPlugin implements CapacitorSQLitePlugin { | ||
@@ -17,2 +17,3 @@ RemoteRef: any; | ||
close(options: capSQLiteOptions): Promise<void>; | ||
checkConnectionsConsistency(options: capAllConnectionsOptions): Promise<void>; | ||
execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges>; | ||
@@ -19,0 +20,0 @@ executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges>; |
@@ -130,2 +130,8 @@ import { __awaiter } from "tslib"; | ||
} | ||
checkConnectionsConsistency(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log('checkConsistency', options); | ||
throw this.unimplemented('Not implemented on Electron.'); | ||
}); | ||
} | ||
execute(options) { | ||
@@ -132,0 +138,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -174,3 +174,3 @@ declare module '@capacitor/core' { | ||
* @param options: capSQLitePathOptions | ||
* @returns Promise<capSQLiteResult> | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.5 | ||
@@ -182,6 +182,14 @@ */ | ||
* @param options: capSQLitePathOptions | ||
* @returns Promise<capSQLiteResult> | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.5 | ||
*/ | ||
deleteOldDatabases(options: capSQLitePathOptions): Promise<void>; | ||
/** | ||
* Check Connection Consistency JS <=> Native | ||
* if inconsistency all connections are removed | ||
* @param options: capAllConnectionsOptions | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
checkConnectionsConsistency(options: capAllConnectionsOptions): Promise<void>; | ||
} | ||
@@ -213,2 +221,9 @@ export interface capEchoOptions { | ||
} | ||
export interface capAllConnectionsOptions { | ||
/** | ||
* the dbName of all connections | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
dbNames?: string[]; | ||
} | ||
export interface capSQLiteOptions { | ||
@@ -229,2 +244,8 @@ /** | ||
statements?: string; | ||
/** | ||
* Enable / Disable transactions | ||
* default Enable (true) | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
transaction?: boolean; | ||
} | ||
@@ -240,2 +261,8 @@ export interface capSQLiteSetOptions { | ||
set?: capSQLiteSet[]; | ||
/** | ||
* Enable / Disable transactions | ||
* default Enable (true) | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
transaction?: boolean; | ||
} | ||
@@ -255,2 +282,8 @@ export interface capSQLiteRunOptions { | ||
values?: any[]; | ||
/** | ||
* Enable / Disable transactions | ||
* default Enable (true) | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
transaction?: boolean; | ||
} | ||
@@ -556,2 +589,10 @@ export interface capSQLiteQueryOptions { | ||
/** | ||
* Check the consistency between Js Connections | ||
* and Native Connections | ||
* if inconsistency all connections are removed | ||
* @returns Promise<void> | ||
* @since 3.0.0-beta.10 | ||
*/ | ||
checkConnectionsConsistency(): Promise<void>; | ||
/** | ||
* Import a database From a JSON | ||
@@ -619,2 +660,3 @@ * @param jsonstring string | ||
closeAllConnections(): Promise<void>; | ||
checkConnectionsConsistency(): Promise<void>; | ||
importFromJson(jsonstring: string): Promise<capSQLiteChanges>; | ||
@@ -656,3 +698,3 @@ isJsonValid(jsonstring: string): Promise<capSQLiteResult>; | ||
*/ | ||
execute(statements: string): Promise<capSQLiteChanges>; | ||
execute(statements: string, transaction?: boolean): Promise<capSQLiteChanges>; | ||
/** | ||
@@ -673,3 +715,3 @@ * Execute SQLite DB Connection Query | ||
*/ | ||
run(statement: string, values?: any[]): Promise<capSQLiteChanges>; | ||
run(statement: string, values?: any[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
/** | ||
@@ -681,3 +723,3 @@ * Execute SQLite DB Connection Set | ||
*/ | ||
executeSet(set: capSQLiteSet[]): Promise<capSQLiteChanges>; | ||
executeSet(set: capSQLiteSet[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
/** | ||
@@ -745,6 +787,6 @@ * Check if a SQLite DB Connection exists | ||
close(): Promise<void>; | ||
execute(statements: string): Promise<capSQLiteChanges>; | ||
execute(statements: string, transaction?: boolean): Promise<capSQLiteChanges>; | ||
query(statement: string, values?: string[]): Promise<capSQLiteValues>; | ||
run(statement: string, values?: any[]): Promise<capSQLiteChanges>; | ||
executeSet(set: capSQLiteSet[]): Promise<capSQLiteChanges>; | ||
run(statement: string, values?: any[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
executeSet(set: capSQLiteSet[], transaction?: boolean): Promise<capSQLiteChanges>; | ||
isExists(): Promise<capSQLiteResult>; | ||
@@ -751,0 +793,0 @@ isTable(table: string): Promise<capSQLiteResult>; |
@@ -44,2 +44,4 @@ import { __awaiter } from "tslib"; | ||
}); | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
const conn = new SQLiteDBConnection(database, this.sqlite); | ||
@@ -57,2 +59,4 @@ this._connectionDict.set(database, conn); | ||
try { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
yield this.sqlite.closeConnection({ database }); | ||
@@ -70,4 +74,7 @@ this._connectionDict.delete(database); | ||
const res = {}; | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
res.result = this._connectionDict.has(database); | ||
return res; | ||
console.log(`isConnection ${res.result}`); | ||
return Promise.resolve(res); | ||
}); | ||
@@ -77,2 +84,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
if (this._connectionDict.has(database)) { | ||
@@ -114,2 +123,18 @@ const conn = this._connectionDict.get(database); | ||
} | ||
checkConnectionsConsistency() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const keys = [...this._connectionDict.keys()]; | ||
yield this.sqlite.checkConnectionsConsistency({ | ||
dbNames: keys, | ||
}); | ||
return Promise.resolve(); | ||
} | ||
catch (err) { | ||
console.log(`checkConnectionsConsistency ${err}`); | ||
this._connectionDict = new Map(); | ||
return Promise.reject('You must redefined the connection'); | ||
} | ||
}); | ||
} | ||
importFromJson(jsonstring) { | ||
@@ -150,2 +175,4 @@ return __awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (database.endsWith('.db')) | ||
database = database.slice(0, -3); | ||
try { | ||
@@ -231,8 +258,10 @@ const res = yield this.sqlite.isDatabase({ database: database }); | ||
} | ||
execute(statements) { | ||
execute(statements, transaction) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const trans = transaction ? transaction : true; | ||
const res = yield this.sqlite.execute({ | ||
database: this.dbName, | ||
statements: statements, | ||
transaction: trans, | ||
}); | ||
@@ -271,4 +300,5 @@ return Promise.resolve(res); | ||
} | ||
run(statement, values) { | ||
run(statement, values, transaction) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const trans = transaction ? transaction : true; | ||
let res; | ||
@@ -281,2 +311,3 @@ try { | ||
values: values, | ||
transaction: trans, | ||
}); | ||
@@ -289,2 +320,3 @@ } | ||
values: [], | ||
transaction: trans, | ||
}); | ||
@@ -299,4 +331,5 @@ } | ||
} | ||
executeSet(set) { | ||
executeSet(set, transaction) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const trans = transaction ? transaction : true; | ||
try { | ||
@@ -306,2 +339,3 @@ const res = yield this.sqlite.executeSet({ | ||
set: set, | ||
transaction: trans, | ||
}); | ||
@@ -308,0 +342,0 @@ return Promise.resolve(res); |
@@ -26,2 +26,3 @@ import { WebPlugin } from '@capacitor/core'; | ||
JsonSQLite, | ||
capAllConnectionsOptions, | ||
} from './definitions'; | ||
@@ -167,2 +168,7 @@ import { Database } from './electron-utils/Database'; | ||
} | ||
async checkConnectionsConsistency(options: capAllConnectionsOptions): Promise<void> { | ||
console.log('checkConsistency', options); | ||
throw this.unimplemented('Not implemented on Electron.'); | ||
} | ||
async execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges> { | ||
@@ -169,0 +175,0 @@ let keys = Object.keys(options); |
{ | ||
"name": "@capacitor-community/sqlite", | ||
"version": "3.0.0-beta.9", | ||
"version": "3.0.0-beta.10", | ||
"description": "Community plugin for native & electron SQLite databases", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js", |
@@ -165,31 +165,55 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||
| Name | Android | iOS | Electron Mac | Electron Windows | Web | | ||
| :---------------------- | :------ | :-- | :----------- | :--------------- | :-- | | ||
| createConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| closeConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| open (non-encrypted DB) | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| open (encrypted DB) | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| close | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| execute | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| executeSet | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| run | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| query | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| deleteDatabase | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| importFromJson | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| exportToJson | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| createSyncTable | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| setSyncDate | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| getSyncDate | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isJsonValid | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isDBExists | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| addUpgradeStatement | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| copyFromAssets | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isDBOpen | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isDatabase | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isTableExists | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| getDatabaseList | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| addSQLiteSuffix | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| deleteOldDatabases | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| Name | Android | iOS | Electron Mac | Electron Windows | Web | | ||
| :-------------------------- | :------ | :-- | :----------- | :--------------- | :-- | | ||
| createConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| closeConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| open (non-encrypted DB) | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| open (encrypted DB) | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| close | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| execute | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| executeSet | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| run | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| query | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| deleteDatabase | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| importFromJson | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| exportToJson | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| createSyncTable | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| setSyncDate | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| getSyncDate | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isJsonValid | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isDBExists | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| addUpgradeStatement | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| copyFromAssets | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isDBOpen | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isDatabase | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| isTableExists | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| getDatabaseList | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| addSQLiteSuffix | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| deleteOldDatabases | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
| checkConnectionsConsistency | ✅ | ✅ | 🚧 | 🚧 | ❌ | | ||
## Supported SQLite Types | ||
Only the following types are allowed in `TABLE creation`. | ||
They have been tested in each methods of the plugin: | ||
- NULL | ||
- INTEGER | ||
- REAL | ||
- TEXT | ||
- BLOB | ||
The Boolean values can be stored as INTEGER. | ||
The Date and Time can be stored as: | ||
- TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS"). | ||
- REAL as Julian day numbers, the number of days since noon in Greenwich | ||
on November 24, 4714 B.C. according to the proleptic Gregorian calendar. | ||
- INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC. | ||
The other types used in other RDBMS should be converted to one of the 5 SQLite types | ||
when importing or exporting table's schemas and/or data. | ||
## Documentation | ||
@@ -196,0 +220,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1637894
16894
291