@capacitor-community/sqlite 5.6.0 → 5.6.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/web.d.ts +0 -2
- package/dist/esm/web.js +56 -210
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +49 -519
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +49 -519
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +1 -1
- package/electron/dist/plugin.js.map +1 -1
- package/package.json +2 -2
- package/src/web.ts +63 -209
- package/dist/esm/web-typeorm-utils/database.d.ts +0 -21
- package/dist/esm/web-typeorm-utils/database.js +0 -91
- package/dist/esm/web-typeorm-utils/database.js.map +0 -1
- package/dist/esm/web-typeorm-utils/utilsSQLite.d.ts +0 -28
- package/dist/esm/web-typeorm-utils/utilsSQLite.js +0 -233
- package/dist/esm/web-typeorm-utils/utilsSQLite.js.map +0 -1
- package/src/web-typeorm-utils/database.ts +0 -111
- package/src/web-typeorm-utils/utilsSQLite.ts +0 -249
package/dist/plugin.js
CHANGED
|
@@ -947,335 +947,11 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
947
947
|
electron: () => window.CapacitorCustomPlatform.plugins.CapacitorSQLite,
|
|
948
948
|
});
|
|
949
949
|
|
|
950
|
-
/************************************************
|
|
951
|
-
* Only to be used to run TypeOrm Cli
|
|
952
|
-
* migration:generate
|
|
953
|
-
* A in-memory database is used
|
|
954
|
-
************************************************
|
|
955
|
-
*/
|
|
956
|
-
class UtilsSQLite {
|
|
957
|
-
constructor() {
|
|
958
|
-
this.isExists = false;
|
|
959
|
-
this.retExists = { isExists: false, pathWasm: '' };
|
|
960
|
-
this.initSqlJs = require('sql.js');
|
|
961
|
-
this.OS = require('os');
|
|
962
|
-
this.FS = require('fs');
|
|
963
|
-
this.Path = require('path');
|
|
964
|
-
}
|
|
965
|
-
getTypeOrmDBFolder() {
|
|
966
|
-
// Find the index of the "node_modules" string in the path
|
|
967
|
-
const nodeModulesIndex = __dirname.indexOf('node_modules');
|
|
968
|
-
// Extract the part of the path before "node_modules"
|
|
969
|
-
const outputPath = __dirname.slice(0, nodeModulesIndex);
|
|
970
|
-
// Extract the App name
|
|
971
|
-
const appName = this.Path.basename(outputPath);
|
|
972
|
-
// Get the Documents path
|
|
973
|
-
const documentsDirectory = this.Path.join(this.OS.homedir(), 'Documents');
|
|
974
|
-
// Add "CapacitorSQLite" and appName
|
|
975
|
-
const outputFolderPath = this.Path.join(documentsDirectory, 'CapacitorSQLite', appName);
|
|
976
|
-
// Ensure the output folder exists
|
|
977
|
-
this.FS.mkdirSync(outputFolderPath, { recursive: true });
|
|
978
|
-
return outputFolderPath;
|
|
979
|
-
}
|
|
980
|
-
getTypeOrmDBPath(outputFolderPath, dbName) {
|
|
981
|
-
return this.Path.resolve(outputFolderPath, dbName);
|
|
982
|
-
}
|
|
983
|
-
async checkFileExistence(wasmPath) {
|
|
984
|
-
// check if a public folder exists
|
|
985
|
-
const folder = (await this.checkFolderExistence('public'))
|
|
986
|
-
? 'public'
|
|
987
|
-
: 'src';
|
|
988
|
-
const pathWasm = this.Path.join(folder, wasmPath);
|
|
989
|
-
const retObj = {};
|
|
990
|
-
retObj.pathWasm = pathWasm;
|
|
991
|
-
try {
|
|
992
|
-
if (this.FS.existsSync(pathWasm)) {
|
|
993
|
-
retObj.isExists = true;
|
|
994
|
-
return Promise.resolve(retObj);
|
|
995
|
-
}
|
|
996
|
-
else {
|
|
997
|
-
retObj.isExists = false;
|
|
998
|
-
return Promise.resolve(retObj);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
catch (err) {
|
|
1002
|
-
retObj.isExists = false;
|
|
1003
|
-
return Promise.resolve(retObj);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
async checkFolderExistence(folder) {
|
|
1007
|
-
try {
|
|
1008
|
-
if (this.FS.existsSync(folder)) {
|
|
1009
|
-
return Promise.resolve(true);
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
return Promise.resolve(false);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
catch (err) {
|
|
1016
|
-
return Promise.resolve(false);
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
async openOrCreateDatabase(wasmPath, databasePath) {
|
|
1020
|
-
let mDB;
|
|
1021
|
-
const msg = 'OpenOrCreateDatabase';
|
|
1022
|
-
try {
|
|
1023
|
-
this.retExists = await this.checkFileExistence(wasmPath);
|
|
1024
|
-
this.isExists = this.retExists.isExists;
|
|
1025
|
-
}
|
|
1026
|
-
catch (err) {
|
|
1027
|
-
this.isExists = false;
|
|
1028
|
-
}
|
|
1029
|
-
if (!this.isExists) {
|
|
1030
|
-
return Promise.reject(msg + ' No sql-wasm.wasm found in ' + wasmPath);
|
|
1031
|
-
}
|
|
1032
|
-
try {
|
|
1033
|
-
const config = {
|
|
1034
|
-
locateFile: (file) => `${this.retExists.pathWasm}/${file}`,
|
|
1035
|
-
};
|
|
1036
|
-
const SQL = await this.initSqlJs(config);
|
|
1037
|
-
// Check if the database exists
|
|
1038
|
-
if (!this.FS.existsSync(databasePath)) {
|
|
1039
|
-
mDB = new SQL.Database();
|
|
1040
|
-
}
|
|
1041
|
-
else {
|
|
1042
|
-
// Read the database file from the local disk
|
|
1043
|
-
const fileBuffer = this.FS.readFileSync(databasePath);
|
|
1044
|
-
// Create a new database instance
|
|
1045
|
-
mDB = new SQL.Database(fileBuffer);
|
|
1046
|
-
}
|
|
1047
|
-
return Promise.resolve(mDB);
|
|
1048
|
-
}
|
|
1049
|
-
catch (err) {
|
|
1050
|
-
return Promise.reject(msg + ' open database failed');
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
async saveDatabase(mDb, outputPath) {
|
|
1054
|
-
try {
|
|
1055
|
-
// Export the modified database to a Uint8Array
|
|
1056
|
-
const data = mDb.export();
|
|
1057
|
-
// Write the Uint8Array to a file on the local disk
|
|
1058
|
-
this.FS.writeFileSync(outputPath, Buffer.from(data));
|
|
1059
|
-
return Promise.resolve();
|
|
1060
|
-
}
|
|
1061
|
-
catch (error) {
|
|
1062
|
-
return Promise.reject(error);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
closeDB(mDB) {
|
|
1066
|
-
const msg = 'closeDB';
|
|
1067
|
-
try {
|
|
1068
|
-
mDB.close();
|
|
1069
|
-
return Promise.resolve();
|
|
1070
|
-
}
|
|
1071
|
-
catch (err) {
|
|
1072
|
-
const errmsg = err.message ? err.message : err;
|
|
1073
|
-
return Promise.reject(`${msg} ${errmsg}`);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
async dbChanges(mDB) {
|
|
1077
|
-
const SELECT_CHANGE = 'SELECT total_changes()';
|
|
1078
|
-
let changes = 0;
|
|
1079
|
-
try {
|
|
1080
|
-
const res = mDB.exec(SELECT_CHANGE);
|
|
1081
|
-
// process the row here
|
|
1082
|
-
changes = res[0].values[0][0];
|
|
1083
|
-
return Promise.resolve(changes);
|
|
1084
|
-
}
|
|
1085
|
-
catch (err) {
|
|
1086
|
-
const errmsg = err.message ? err.message : err;
|
|
1087
|
-
return Promise.reject(`DbChanges failed: ${errmsg}`);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
async getLastId(mDB) {
|
|
1091
|
-
const SELECT_LAST_ID = 'SELECT last_insert_rowid()';
|
|
1092
|
-
let lastId = -1;
|
|
1093
|
-
try {
|
|
1094
|
-
const res = mDB.exec(SELECT_LAST_ID);
|
|
1095
|
-
// process the row here
|
|
1096
|
-
lastId = res[0].values[0][0];
|
|
1097
|
-
return Promise.resolve(lastId);
|
|
1098
|
-
}
|
|
1099
|
-
catch (err) {
|
|
1100
|
-
const errmsg = err.message ? err.message : err;
|
|
1101
|
-
return Promise.reject(new Error(`GetLastId failed: ${errmsg}`));
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
async execute(mDB, sql) {
|
|
1105
|
-
try {
|
|
1106
|
-
mDB.exec(sql);
|
|
1107
|
-
const changes = await this.dbChanges(mDB);
|
|
1108
|
-
return Promise.resolve(changes);
|
|
1109
|
-
}
|
|
1110
|
-
catch (err) {
|
|
1111
|
-
const errmsg = err.message ? err.message : err;
|
|
1112
|
-
return Promise.reject(new Error(`Execute failed: ${errmsg}`));
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
async run(mDB, statement, values, returnMode) {
|
|
1116
|
-
let res;
|
|
1117
|
-
let retValues = [];
|
|
1118
|
-
const retObj = {};
|
|
1119
|
-
try {
|
|
1120
|
-
if (values.length > 0) {
|
|
1121
|
-
res = mDB.exec(statement, values);
|
|
1122
|
-
}
|
|
1123
|
-
else {
|
|
1124
|
-
res = mDB.exec(statement);
|
|
1125
|
-
}
|
|
1126
|
-
if (returnMode === 'all' || returnMode === 'one') {
|
|
1127
|
-
if (res && res.length > 0) {
|
|
1128
|
-
retValues = this.getReturnedValues(res[0], returnMode);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
const lastId = await this.getLastId(mDB);
|
|
1132
|
-
retObj['lastId'] = lastId;
|
|
1133
|
-
if (retValues != null && retValues.length > 0)
|
|
1134
|
-
retObj['values'] = retValues;
|
|
1135
|
-
return Promise.resolve(retObj);
|
|
1136
|
-
}
|
|
1137
|
-
catch (err) {
|
|
1138
|
-
const errmsg = err.message ? err.message : err;
|
|
1139
|
-
return Promise.reject(new Error(`Run failed: ${errmsg}`));
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
getReturnedValues(result, returnMode) {
|
|
1143
|
-
const retValues = [];
|
|
1144
|
-
for (const values of result.values) {
|
|
1145
|
-
const row = {};
|
|
1146
|
-
for (let j = 0; j < result.columns.length; j++) {
|
|
1147
|
-
row[result.columns[j]] = values[j];
|
|
1148
|
-
}
|
|
1149
|
-
retValues.push(row);
|
|
1150
|
-
if (returnMode === 'one') {
|
|
1151
|
-
break;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
return retValues;
|
|
1155
|
-
}
|
|
1156
|
-
async queryAll(mDB, sql, values) {
|
|
1157
|
-
try {
|
|
1158
|
-
let retArr = [];
|
|
1159
|
-
if (values != null && values.length > 0) {
|
|
1160
|
-
retArr = mDB.exec(sql, values);
|
|
1161
|
-
}
|
|
1162
|
-
else {
|
|
1163
|
-
retArr = mDB.exec(sql);
|
|
1164
|
-
}
|
|
1165
|
-
if (retArr.length == 0)
|
|
1166
|
-
return Promise.resolve([]);
|
|
1167
|
-
const result = retArr[0].values.map((entry) => {
|
|
1168
|
-
const obj = {};
|
|
1169
|
-
retArr[0].columns.forEach((column, index) => {
|
|
1170
|
-
obj[`${column}`] = entry[index];
|
|
1171
|
-
});
|
|
1172
|
-
return obj;
|
|
1173
|
-
});
|
|
1174
|
-
return Promise.resolve(result);
|
|
1175
|
-
}
|
|
1176
|
-
catch (err) {
|
|
1177
|
-
const errmsg = err.message ? err.message : err;
|
|
1178
|
-
return Promise.reject(new Error(`queryAll: ${errmsg}`));
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
/************************************************
|
|
1184
|
-
* Only to be used to run TypeOrm Cli
|
|
1185
|
-
* migration:generate
|
|
1186
|
-
* A in-memory database is used
|
|
1187
|
-
************************************************
|
|
1188
|
-
*/
|
|
1189
|
-
class Database {
|
|
1190
|
-
constructor() {
|
|
1191
|
-
this.wasmPath = 'assets';
|
|
1192
|
-
this.sqliteUtil = new UtilsSQLite();
|
|
1193
|
-
this.typeOrmDBFolder = this.sqliteUtil.getTypeOrmDBFolder();
|
|
1194
|
-
this.dbPath = '';
|
|
1195
|
-
this.mDb = null;
|
|
1196
|
-
this._isDBOpen = false;
|
|
1197
|
-
}
|
|
1198
|
-
async open(dbName) {
|
|
1199
|
-
try {
|
|
1200
|
-
this.dbPath = this.sqliteUtil.getTypeOrmDBPath(this.typeOrmDBFolder, `${dbName}SQLite.db`);
|
|
1201
|
-
this.mDb = await this.sqliteUtil.openOrCreateDatabase(this.wasmPath, this.dbPath);
|
|
1202
|
-
this._isDBOpen = true;
|
|
1203
|
-
return Promise.resolve();
|
|
1204
|
-
}
|
|
1205
|
-
catch (err) {
|
|
1206
|
-
return Promise.reject(`Open: ${err}`);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
async close() {
|
|
1210
|
-
try {
|
|
1211
|
-
if (this._isDBOpen) {
|
|
1212
|
-
await this.sqliteUtil.saveDatabase(this.mDb, this.dbPath);
|
|
1213
|
-
await this.mDb.close();
|
|
1214
|
-
}
|
|
1215
|
-
return Promise.resolve();
|
|
1216
|
-
}
|
|
1217
|
-
catch (err) {
|
|
1218
|
-
return Promise.reject(`Close: ${err}`);
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
async executeSQL(statements) {
|
|
1222
|
-
let changes = -1;
|
|
1223
|
-
try {
|
|
1224
|
-
if (this._isDBOpen) {
|
|
1225
|
-
const initChanges = await this.sqliteUtil.dbChanges(this.mDb);
|
|
1226
|
-
changes = await this.sqliteUtil.execute(this.mDb, statements);
|
|
1227
|
-
if (changes < 0) {
|
|
1228
|
-
return Promise.reject(new Error('ExecuteSQL: changes < 0'));
|
|
1229
|
-
}
|
|
1230
|
-
changes = (await this.sqliteUtil.dbChanges(this.mDb)) - initChanges;
|
|
1231
|
-
}
|
|
1232
|
-
return Promise.resolve(changes);
|
|
1233
|
-
}
|
|
1234
|
-
catch (err) {
|
|
1235
|
-
return Promise.reject(`ExecuteSQL: ${err}`);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
async run(statement, values, returnMode) {
|
|
1239
|
-
const retRes = { changes: -1, lastId: -1 };
|
|
1240
|
-
try {
|
|
1241
|
-
if (this._isDBOpen) {
|
|
1242
|
-
const initChanges = await this.sqliteUtil.dbChanges(this.mDb);
|
|
1243
|
-
const retObj = await this.sqliteUtil.run(this.mDb, statement, values, returnMode);
|
|
1244
|
-
const lastId = retObj['lastId'];
|
|
1245
|
-
if (lastId < 0) {
|
|
1246
|
-
return Promise.reject(new Error('RunSQL: lastId < 0'));
|
|
1247
|
-
}
|
|
1248
|
-
const changes = (await this.sqliteUtil.dbChanges(this.mDb)) - initChanges;
|
|
1249
|
-
retRes.changes = changes;
|
|
1250
|
-
retRes.lastId = lastId;
|
|
1251
|
-
retRes.values = retObj['values'] ? retObj['values'] : [];
|
|
1252
|
-
}
|
|
1253
|
-
return Promise.resolve({ changes: retRes });
|
|
1254
|
-
}
|
|
1255
|
-
catch (err) {
|
|
1256
|
-
return Promise.reject(`Run: ${err}`);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
async selectSQL(sql, values) {
|
|
1260
|
-
let retArr = [];
|
|
1261
|
-
try {
|
|
1262
|
-
if (this._isDBOpen) {
|
|
1263
|
-
retArr = await this.sqliteUtil.queryAll(this.mDb, sql, values);
|
|
1264
|
-
}
|
|
1265
|
-
return Promise.resolve({ values: retArr });
|
|
1266
|
-
}
|
|
1267
|
-
catch (err) {
|
|
1268
|
-
return Promise.reject(`SelectSQL: ${err}`);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
950
|
class CapacitorSQLiteWeb extends core.WebPlugin {
|
|
1274
951
|
constructor() {
|
|
1275
952
|
super(...arguments);
|
|
1276
953
|
this.jeepSqliteElement = null;
|
|
1277
954
|
this.isWebStoreOpen = false;
|
|
1278
|
-
this.databases = {};
|
|
1279
955
|
}
|
|
1280
956
|
async initWebStore() {
|
|
1281
957
|
await customElements.whenDefined('jeep-sqlite');
|
|
@@ -1340,88 +1016,36 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
1340
1016
|
return echoResult;
|
|
1341
1017
|
}
|
|
1342
1018
|
async createConnection(options) {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
catch (err) {
|
|
1351
|
-
throw new Error(`${err}`);
|
|
1352
|
-
}
|
|
1019
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1020
|
+
this.ensureWebstoreIsOpen();
|
|
1021
|
+
try {
|
|
1022
|
+
await this.jeepSqliteElement.createConnection(options);
|
|
1023
|
+
return;
|
|
1353
1024
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
const optionKeys = Object.keys(options);
|
|
1357
|
-
let dbName;
|
|
1358
|
-
if (!optionKeys.includes('database')) {
|
|
1359
|
-
throw new Error('Must provide a database name');
|
|
1360
|
-
}
|
|
1361
|
-
else {
|
|
1362
|
-
dbName = options.database;
|
|
1363
|
-
}
|
|
1364
|
-
const connName = 'RW_' + dbName;
|
|
1365
|
-
const databaseConnection = new Database();
|
|
1366
|
-
this.databases[connName] = databaseConnection;
|
|
1025
|
+
catch (err) {
|
|
1026
|
+
throw new Error(`${err}`);
|
|
1367
1027
|
}
|
|
1368
1028
|
}
|
|
1369
1029
|
async open(options) {
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
return;
|
|
1376
|
-
}
|
|
1377
|
-
catch (err) {
|
|
1378
|
-
throw new Error(`${err}`);
|
|
1379
|
-
}
|
|
1030
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1031
|
+
this.ensureWebstoreIsOpen();
|
|
1032
|
+
try {
|
|
1033
|
+
await this.jeepSqliteElement.open(options);
|
|
1034
|
+
return;
|
|
1380
1035
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
const dbName = options.database ? options.database : '';
|
|
1384
|
-
if (dbName.length === 0) {
|
|
1385
|
-
throw new Error('Must provide a database name');
|
|
1386
|
-
}
|
|
1387
|
-
const connName = 'RW_' + dbName;
|
|
1388
|
-
const database = this.getDatabaseConnectionOrThrowError(connName);
|
|
1389
|
-
try {
|
|
1390
|
-
await database.open(dbName);
|
|
1391
|
-
}
|
|
1392
|
-
catch (err) {
|
|
1393
|
-
throw new Error(`### open ${err}`);
|
|
1394
|
-
}
|
|
1036
|
+
catch (err) {
|
|
1037
|
+
throw new Error(`${err}`);
|
|
1395
1038
|
}
|
|
1396
1039
|
}
|
|
1397
1040
|
async closeConnection(options) {
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
catch (err) {
|
|
1406
|
-
throw new Error(`${err}`);
|
|
1407
|
-
}
|
|
1041
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1042
|
+
this.ensureWebstoreIsOpen();
|
|
1043
|
+
try {
|
|
1044
|
+
await this.jeepSqliteElement.closeConnection(options);
|
|
1045
|
+
return;
|
|
1408
1046
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
const dbName = options.database ? options.database : '';
|
|
1412
|
-
if (dbName.length === 0) {
|
|
1413
|
-
throw new Error('Must provide a database name');
|
|
1414
|
-
}
|
|
1415
|
-
const connName = 'RW_' + dbName;
|
|
1416
|
-
const database = this.getDatabaseConnectionOrThrowError(connName);
|
|
1417
|
-
try {
|
|
1418
|
-
await database.close();
|
|
1419
|
-
// remove the connection from dictionary
|
|
1420
|
-
delete this.databases[connName];
|
|
1421
|
-
}
|
|
1422
|
-
catch (err) {
|
|
1423
|
-
throw new Error(`### closeConnection ${err}`);
|
|
1424
|
-
}
|
|
1047
|
+
catch (err) {
|
|
1048
|
+
throw new Error(`${err}`);
|
|
1425
1049
|
}
|
|
1426
1050
|
}
|
|
1427
1051
|
async getVersion(options) {
|
|
@@ -1446,31 +1070,14 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
1446
1070
|
}
|
|
1447
1071
|
}
|
|
1448
1072
|
async close(options) {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
|
-
catch (err) {
|
|
1457
|
-
throw new Error(`${err}`);
|
|
1458
|
-
}
|
|
1073
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1074
|
+
this.ensureWebstoreIsOpen();
|
|
1075
|
+
try {
|
|
1076
|
+
await this.jeepSqliteElement.close(options);
|
|
1077
|
+
return;
|
|
1459
1078
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
const dbName = options.database ? options.database : '';
|
|
1463
|
-
if (dbName.length === 0) {
|
|
1464
|
-
throw new Error('Must provide a database name');
|
|
1465
|
-
}
|
|
1466
|
-
const connName = 'RW_' + dbName;
|
|
1467
|
-
const database = this.getDatabaseConnectionOrThrowError(connName);
|
|
1468
|
-
try {
|
|
1469
|
-
await database.close();
|
|
1470
|
-
}
|
|
1471
|
-
catch (err) {
|
|
1472
|
-
throw new Error(`### close ${err}`);
|
|
1473
|
-
}
|
|
1079
|
+
catch (err) {
|
|
1080
|
+
throw new Error(`${err}`);
|
|
1474
1081
|
}
|
|
1475
1082
|
}
|
|
1476
1083
|
async beginTransaction(options) {
|
|
@@ -1529,37 +1136,14 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
1529
1136
|
}
|
|
1530
1137
|
}
|
|
1531
1138
|
async execute(options) {
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
return executeResult;
|
|
1538
|
-
}
|
|
1539
|
-
catch (err) {
|
|
1540
|
-
throw new Error(`${err}`);
|
|
1541
|
-
}
|
|
1139
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1140
|
+
this.ensureWebstoreIsOpen();
|
|
1141
|
+
try {
|
|
1142
|
+
const executeResult = await this.jeepSqliteElement.execute(options);
|
|
1143
|
+
return executeResult;
|
|
1542
1144
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
const dbName = options.database ? options.database : '';
|
|
1546
|
-
if (dbName.length === 0) {
|
|
1547
|
-
throw new Error('Must provide a database name');
|
|
1548
|
-
}
|
|
1549
|
-
const statements = options.statements ? options.statements : '';
|
|
1550
|
-
if (statements.length === 0) {
|
|
1551
|
-
return Promise.reject('Must provide raw SQL statements');
|
|
1552
|
-
}
|
|
1553
|
-
const connName = 'RW_' + dbName;
|
|
1554
|
-
const database = this.getDatabaseConnectionOrThrowError(connName);
|
|
1555
|
-
try {
|
|
1556
|
-
const ret = await database.executeSQL(statements);
|
|
1557
|
-
const executeResult = { changes: { changes: ret } };
|
|
1558
|
-
return executeResult;
|
|
1559
|
-
}
|
|
1560
|
-
catch (err) {
|
|
1561
|
-
throw new Error(`${err}`);
|
|
1562
|
-
}
|
|
1145
|
+
catch (err) {
|
|
1146
|
+
throw new Error(`${err}`);
|
|
1563
1147
|
}
|
|
1564
1148
|
}
|
|
1565
1149
|
async executeSet(options) {
|
|
@@ -1574,72 +1158,25 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
1574
1158
|
}
|
|
1575
1159
|
}
|
|
1576
1160
|
async run(options) {
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
return runResult;
|
|
1583
|
-
}
|
|
1584
|
-
catch (err) {
|
|
1585
|
-
throw new Error(`${err}`);
|
|
1586
|
-
}
|
|
1161
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1162
|
+
this.ensureWebstoreIsOpen();
|
|
1163
|
+
try {
|
|
1164
|
+
const runResult = await this.jeepSqliteElement.run(options);
|
|
1165
|
+
return runResult;
|
|
1587
1166
|
}
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
const dbName = options.database ? options.database : '';
|
|
1591
|
-
if (dbName.length === 0) {
|
|
1592
|
-
throw new Error('Must provide a database name');
|
|
1593
|
-
}
|
|
1594
|
-
const statement = options.statement ? options.statement : '';
|
|
1595
|
-
if (statement.length === 0) {
|
|
1596
|
-
return Promise.reject('Must provide raw SQL statement');
|
|
1597
|
-
}
|
|
1598
|
-
const values = options.values ? options.values : [];
|
|
1599
|
-
const returnMode = options.returnMode ? options.returnMode : 'no';
|
|
1600
|
-
const connName = 'RW_' + dbName;
|
|
1601
|
-
const database = this.getDatabaseConnectionOrThrowError(connName);
|
|
1602
|
-
try {
|
|
1603
|
-
const runResult = await database.run(statement, values, returnMode);
|
|
1604
|
-
return runResult;
|
|
1605
|
-
}
|
|
1606
|
-
catch (err) {
|
|
1607
|
-
throw new Error(`${err}`);
|
|
1608
|
-
}
|
|
1167
|
+
catch (err) {
|
|
1168
|
+
throw new Error(`${err}`);
|
|
1609
1169
|
}
|
|
1610
1170
|
}
|
|
1611
1171
|
async query(options) {
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
return queryResult;
|
|
1618
|
-
}
|
|
1619
|
-
catch (err) {
|
|
1620
|
-
throw new Error(`${err}`);
|
|
1621
|
-
}
|
|
1172
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1173
|
+
this.ensureWebstoreIsOpen();
|
|
1174
|
+
try {
|
|
1175
|
+
const queryResult = await this.jeepSqliteElement.query(options);
|
|
1176
|
+
return queryResult;
|
|
1622
1177
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
const dbName = options.database ? options.database : '';
|
|
1626
|
-
if (dbName.length === 0) {
|
|
1627
|
-
throw new Error('Must provide a database name');
|
|
1628
|
-
}
|
|
1629
|
-
const statement = options.statement ? options.statement : '';
|
|
1630
|
-
if (statement.length === 0) {
|
|
1631
|
-
return Promise.reject('Must provide raw SQL statement');
|
|
1632
|
-
}
|
|
1633
|
-
const values = options.values ? options.values : [];
|
|
1634
|
-
const connName = 'RW_' + dbName;
|
|
1635
|
-
const database = this.getDatabaseConnectionOrThrowError(connName);
|
|
1636
|
-
try {
|
|
1637
|
-
const queryResult = await database.selectSQL(statement, values);
|
|
1638
|
-
return queryResult;
|
|
1639
|
-
}
|
|
1640
|
-
catch (err) {
|
|
1641
|
-
throw new Error(`${err}`);
|
|
1642
|
-
}
|
|
1178
|
+
catch (err) {
|
|
1179
|
+
throw new Error(`${err}`);
|
|
1643
1180
|
}
|
|
1644
1181
|
}
|
|
1645
1182
|
async isDBExists(options) {
|
|
@@ -1838,13 +1375,6 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
1838
1375
|
throw new Error('WebStore is not open yet. You have to call "initWebStore()" first.');
|
|
1839
1376
|
}
|
|
1840
1377
|
}
|
|
1841
|
-
getDatabaseConnectionOrThrowError(dbName) {
|
|
1842
|
-
const databaseNames = Object.keys(this.databases);
|
|
1843
|
-
if (!databaseNames.includes(dbName)) {
|
|
1844
|
-
throw new Error(`No connection available for database "${dbName}"`);
|
|
1845
|
-
}
|
|
1846
|
-
return this.databases[dbName];
|
|
1847
|
-
}
|
|
1848
1378
|
////////////////////////////////////
|
|
1849
1379
|
////// UNIMPLEMENTED METHODS
|
|
1850
1380
|
////////////////////////////////////
|