@capacitor-community/sqlite
Advanced tools
Comparing version 2.9.0-alpha.4 to 2.9.0-alpha.5
@@ -0,1 +1,13 @@ | ||
## 2.9.0-alpha.5 (2020-12-02) REFACTOR | ||
### Added Features | ||
- retrieveConnection (Wrapper Connection) | ||
- retrieveAllConnections (Wrapper Connection) | ||
- closeAllConnections (Wrapper Connection) | ||
### Bug Fixes | ||
- fix rollback transaction in iOS | ||
## 2.9.0-alpha.4 (2020-11-29) REFACTOR | ||
@@ -2,0 +14,0 @@ |
@@ -410,2 +410,15 @@ declare module '@capacitor/core' { | ||
/** | ||
* Retrieve an existing database connection | ||
* @param database | ||
* @returns Promise<capSQLiteResult> | ||
* @since 2.9.0 refactor | ||
*/ | ||
retrieveConnection(database: string): Promise<SQLiteDBConnection | null | undefined>; | ||
/** | ||
* Retrieve all database connections | ||
* @returns Promise<capSQLiteResult> | ||
* @since 2.9.0 refactor | ||
*/ | ||
retrieveAllConnections(): Promise<Map<string, SQLiteDBConnection>>; | ||
/** | ||
* Close a database connection | ||
@@ -417,2 +430,8 @@ * @param database | ||
closeConnection(database: string): Promise<capSQLiteResult>; | ||
/** | ||
* Close all database connections | ||
* @returns Promise<capSQLiteResult> | ||
* @since 2.9.0 refactor | ||
*/ | ||
closeAllConnections(): Promise<capSQLiteResult>; | ||
} | ||
@@ -424,2 +443,3 @@ /** | ||
private sqlite; | ||
private _connectionDict; | ||
constructor(sqlite: any); | ||
@@ -430,2 +450,5 @@ echo(value: string): Promise<capEchoResult>; | ||
closeConnection(database: string): Promise<capSQLiteResult>; | ||
retrieveConnection(database: string): Promise<SQLiteDBConnection | null | undefined>; | ||
retrieveAllConnections(): Promise<Map<string, SQLiteDBConnection>>; | ||
closeAllConnections(): Promise<capSQLiteResult>; | ||
} | ||
@@ -432,0 +455,0 @@ /** |
@@ -16,2 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.sqlite = sqlite; | ||
this._connectionDict = new Map(); | ||
} | ||
@@ -47,3 +48,5 @@ echo(value) { | ||
if (res.result) { | ||
return new SQLiteDBConnection(database, this.sqlite); | ||
const conn = new SQLiteDBConnection(database, this.sqlite); | ||
this._connectionDict.set(database, conn); | ||
return conn; | ||
} | ||
@@ -57,5 +60,38 @@ else { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.sqlite.closeConnection({ database }); | ||
const res = yield this.sqlite.closeConnection({ database }); | ||
if (res.result) { | ||
this._connectionDict.delete(database); | ||
} | ||
return res; | ||
}); | ||
} | ||
retrieveConnection(database) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const conn = this._connectionDict.has(database) | ||
? this._connectionDict.get(database) | ||
: null; | ||
return conn; | ||
}); | ||
} | ||
retrieveAllConnections() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this._connectionDict; | ||
}); | ||
} | ||
closeAllConnections() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const delDict = new Map(); | ||
let res; | ||
for (let database of this._connectionDict.keys()) { | ||
res = yield this.sqlite.closeConnection({ database }); | ||
if (!res.result) | ||
break; | ||
delDict.set(database, null); | ||
} | ||
for (let database of delDict.keys()) { | ||
this._connectionDict.delete(database); | ||
} | ||
return res; | ||
}); | ||
} | ||
} | ||
@@ -62,0 +98,0 @@ /** |
@@ -19,2 +19,3 @@ var capacitorPlugin = (function (exports, core) { | ||
this.sqlite = sqlite; | ||
this._connectionDict = new Map(); | ||
} | ||
@@ -50,3 +51,5 @@ echo(value) { | ||
if (res.result) { | ||
return new SQLiteDBConnection(database, this.sqlite); | ||
const conn = new SQLiteDBConnection(database, this.sqlite); | ||
this._connectionDict.set(database, conn); | ||
return conn; | ||
} | ||
@@ -60,5 +63,38 @@ else { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.sqlite.closeConnection({ database }); | ||
const res = yield this.sqlite.closeConnection({ database }); | ||
if (res.result) { | ||
this._connectionDict.delete(database); | ||
} | ||
return res; | ||
}); | ||
} | ||
retrieveConnection(database) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const conn = this._connectionDict.has(database) | ||
? this._connectionDict.get(database) | ||
: null; | ||
return conn; | ||
}); | ||
} | ||
retrieveAllConnections() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this._connectionDict; | ||
}); | ||
} | ||
closeAllConnections() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const delDict = new Map(); | ||
let res; | ||
for (let database of this._connectionDict.keys()) { | ||
res = yield this.sqlite.closeConnection({ database }); | ||
if (!res.result) | ||
break; | ||
delDict.set(database, null); | ||
} | ||
for (let database of delDict.keys()) { | ||
this._connectionDict.delete(database); | ||
} | ||
return res; | ||
}); | ||
} | ||
} | ||
@@ -65,0 +101,0 @@ /** |
{ | ||
"name": "@capacitor-community/sqlite", | ||
"version": "2.9.0-alpha.4", | ||
"version": "2.9.0-alpha.5", | ||
"description": "Capacitor SQLite Plugin", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/capacitor-community/sqlite", |
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
1596407
1348