@capacitor-community/sqlite 5.2.3 → 5.2.5
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/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +5 -6
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +12 -7
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +20 -7
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLCipher.java +62 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLStatement.java +20 -14
- package/dist/esm/definitions.d.ts +6 -6
- package/dist/esm/definitions.js +42 -21
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +42 -21
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +42 -21
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +72 -78
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +1082 -1139
- package/ios/Plugin/CapacitorSQLitePlugin.swift +3 -2
- package/ios/Plugin/Database.swift +27 -3
- package/ios/Plugin/ImportExportJson/ImportFromJson.swift +2 -2
- package/ios/Plugin/Utils/UtilsDelete.swift +2 -3
- package/ios/Plugin/Utils/UtilsEncryption.swift +75 -0
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +3 -3
- package/ios/Plugin/Utils/UtilsSQLStatement.swift +81 -17
- package/ios/Plugin/Utils/UtilsSecret.swift +1 -0
- package/package.json +3 -3
- package/src/definitions.ts +88 -54
- package/src/web.ts +10 -4
package/src/definitions.ts
CHANGED
|
@@ -122,32 +122,32 @@ export interface CapacitorSQLitePlugin {
|
|
|
122
122
|
close(options: capSQLiteOptions): Promise<void>;
|
|
123
123
|
/**
|
|
124
124
|
* Begin Database Transaction
|
|
125
|
-
* @param options
|
|
125
|
+
* @param options
|
|
126
126
|
* @returns capSQLiteChanges
|
|
127
127
|
* @since 5.0.7
|
|
128
128
|
*/
|
|
129
129
|
beginTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges>;
|
|
130
130
|
/**
|
|
131
131
|
* Commit Database Transaction
|
|
132
|
-
* @param options
|
|
132
|
+
* @param options
|
|
133
133
|
* @returns capSQLiteChanges
|
|
134
134
|
* @since 5.0.7
|
|
135
135
|
*/
|
|
136
136
|
commitTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges>;
|
|
137
|
-
|
|
137
|
+
/**
|
|
138
138
|
* Rollback Database Transaction
|
|
139
|
-
* @param options
|
|
139
|
+
* @param options
|
|
140
140
|
* @returns capSQLiteChanges
|
|
141
141
|
* @since 5.0.7
|
|
142
142
|
*/
|
|
143
143
|
rollbackTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges>;
|
|
144
144
|
/**
|
|
145
145
|
* Is Database Transaction Active
|
|
146
|
-
* @param options
|
|
146
|
+
* @param options
|
|
147
147
|
* @returns capSQLiteResult
|
|
148
148
|
* @since 5.0.7
|
|
149
149
|
*/
|
|
150
|
-
isTransactionActive(options: capSQLiteOptions): Promise<capSQLiteResult>;
|
|
150
|
+
isTransactionActive(options: capSQLiteOptions): Promise<capSQLiteResult>;
|
|
151
151
|
/**
|
|
152
152
|
* Load a SQlite extension
|
|
153
153
|
* @param options :capSQLiteExtensionPath
|
|
@@ -417,6 +417,7 @@ export interface capSetSecretOptions {
|
|
|
417
417
|
*/
|
|
418
418
|
passphrase?: string;
|
|
419
419
|
}
|
|
420
|
+
|
|
420
421
|
export interface capChangeSecretOptions {
|
|
421
422
|
/**
|
|
422
423
|
* The new passphrase for Encrypted Databases
|
|
@@ -566,7 +567,6 @@ export interface capSQLiteExecuteOptions {
|
|
|
566
567
|
* @since 5.0.7
|
|
567
568
|
*/
|
|
568
569
|
isSQL92?: boolean;
|
|
569
|
-
|
|
570
570
|
}
|
|
571
571
|
export interface capSQLiteSetOptions {
|
|
572
572
|
/**
|
|
@@ -707,7 +707,7 @@ export interface capSQLiteExportOptions {
|
|
|
707
707
|
* default false
|
|
708
708
|
* @since 5.0.8
|
|
709
709
|
*/
|
|
710
|
-
encrypted?: boolean
|
|
710
|
+
encrypted?: boolean;
|
|
711
711
|
}
|
|
712
712
|
export interface capSQLiteFromAssetsOptions {
|
|
713
713
|
/**
|
|
@@ -1088,6 +1088,7 @@ export interface ISQLiteConnection {
|
|
|
1088
1088
|
* @since 3.0.0-beta.13
|
|
1089
1089
|
*/
|
|
1090
1090
|
isSecretStored(): Promise<capSQLiteResult>;
|
|
1091
|
+
|
|
1091
1092
|
/**
|
|
1092
1093
|
* Set a passphrase in a secure store
|
|
1093
1094
|
* @param passphrase
|
|
@@ -1114,7 +1115,7 @@ export interface ISQLiteConnection {
|
|
|
1114
1115
|
clearEncryptionSecret(): Promise<void>;
|
|
1115
1116
|
/**
|
|
1116
1117
|
* Check the passphrase stored in a secure store
|
|
1117
|
-
* @param
|
|
1118
|
+
* @param oldPassphrase
|
|
1118
1119
|
* @returns Promise<capSQLiteResult>
|
|
1119
1120
|
* @since 4.6.1
|
|
1120
1121
|
*/
|
|
@@ -1482,6 +1483,12 @@ export class SQLiteConnection implements ISQLiteConnection {
|
|
|
1482
1483
|
const conn = new SQLiteDBConnection(database, readonly, this.sqlite);
|
|
1483
1484
|
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
1484
1485
|
this._connectionDict.set(connName, conn);
|
|
1486
|
+
/*
|
|
1487
|
+
console.log(`*** in createConnection connectionDict: ***`)
|
|
1488
|
+
this._connectionDict.forEach((connection, key) => {
|
|
1489
|
+
console.log(`Key: ${key}, Value: ${connection}`);
|
|
1490
|
+
});
|
|
1491
|
+
*/
|
|
1485
1492
|
return Promise.resolve(conn);
|
|
1486
1493
|
} catch (err) {
|
|
1487
1494
|
return Promise.reject(err);
|
|
@@ -1493,6 +1500,11 @@ export class SQLiteConnection implements ISQLiteConnection {
|
|
|
1493
1500
|
await this.sqlite.closeConnection({ database, readonly });
|
|
1494
1501
|
const connName = readonly ? `RO_${database}` : `RW_${database}`;
|
|
1495
1502
|
this._connectionDict.delete(connName);
|
|
1503
|
+
/* console.log(`*** in closeConnection connectionDict: ***`)
|
|
1504
|
+
this._connectionDict.forEach((connection, key) => {
|
|
1505
|
+
console.log(`Key: ${key}, Value: ${connection}`);
|
|
1506
|
+
});
|
|
1507
|
+
*/
|
|
1496
1508
|
return Promise.resolve();
|
|
1497
1509
|
} catch (err) {
|
|
1498
1510
|
return Promise.reject(err);
|
|
@@ -1601,6 +1613,11 @@ export class SQLiteConnection implements ISQLiteConnection {
|
|
|
1601
1613
|
async closeAllConnections(): Promise<void> {
|
|
1602
1614
|
const delDict: Map<string, SQLiteDBConnection | null> = new Map();
|
|
1603
1615
|
try {
|
|
1616
|
+
/* console.log(`*** in closeAllConnections connectionDict: ***`)
|
|
1617
|
+
this._connectionDict.forEach((connection, key) => {
|
|
1618
|
+
console.log(`Key: ${key}, Value: ${connection}`);
|
|
1619
|
+
});
|
|
1620
|
+
*/
|
|
1604
1621
|
for (const key of this._connectionDict.keys()) {
|
|
1605
1622
|
const database = key.substring(3);
|
|
1606
1623
|
const readonly = key.substring(0, 3) === 'RO_' ? true : false;
|
|
@@ -1613,6 +1630,7 @@ export class SQLiteConnection implements ISQLiteConnection {
|
|
|
1613
1630
|
}
|
|
1614
1631
|
return Promise.resolve();
|
|
1615
1632
|
} catch (err) {
|
|
1633
|
+
console.log(`in definition closeAllConnections err: `, err);
|
|
1616
1634
|
return Promise.reject(err);
|
|
1617
1635
|
}
|
|
1618
1636
|
}
|
|
@@ -1829,7 +1847,7 @@ export interface ISQLiteDBConnection {
|
|
|
1829
1847
|
* @returns capSQLiteResult
|
|
1830
1848
|
* @since 5.0.7
|
|
1831
1849
|
*/
|
|
1832
|
-
isTransactionActive(): Promise<capSQLiteResult>;
|
|
1850
|
+
isTransactionActive(): Promise<capSQLiteResult>;
|
|
1833
1851
|
/**
|
|
1834
1852
|
* Get Database Url
|
|
1835
1853
|
* @returns Promise<capSQLiteUrl>
|
|
@@ -1864,7 +1882,11 @@ export interface ISQLiteDBConnection {
|
|
|
1864
1882
|
* @returns Promise<capSQLiteChanges>
|
|
1865
1883
|
* @since 2.9.0 refactor
|
|
1866
1884
|
*/
|
|
1867
|
-
execute(
|
|
1885
|
+
execute(
|
|
1886
|
+
statements: string,
|
|
1887
|
+
transaction?: boolean,
|
|
1888
|
+
isSQL92?: boolean,
|
|
1889
|
+
): Promise<capSQLiteChanges>;
|
|
1868
1890
|
/**
|
|
1869
1891
|
* Execute SQLite DB Connection Query
|
|
1870
1892
|
* @param statement
|
|
@@ -1873,7 +1895,11 @@ export interface ISQLiteDBConnection {
|
|
|
1873
1895
|
* @returns Promise<Promise<DBSQLiteValues>
|
|
1874
1896
|
* @since 2.9.0 refactor
|
|
1875
1897
|
*/
|
|
1876
|
-
query(
|
|
1898
|
+
query(
|
|
1899
|
+
statement: string,
|
|
1900
|
+
values?: any[],
|
|
1901
|
+
isSQL92?: boolean,
|
|
1902
|
+
): Promise<DBSQLiteValues>;
|
|
1877
1903
|
/**
|
|
1878
1904
|
* Execute SQLite DB Connection Raw Statement
|
|
1879
1905
|
* @param statement
|
|
@@ -1889,7 +1915,7 @@ export interface ISQLiteDBConnection {
|
|
|
1889
1915
|
values?: any[],
|
|
1890
1916
|
transaction?: boolean,
|
|
1891
1917
|
returnMode?: string,
|
|
1892
|
-
isSQL92?: boolean
|
|
1918
|
+
isSQL92?: boolean,
|
|
1893
1919
|
): Promise<capSQLiteChanges>;
|
|
1894
1920
|
/**
|
|
1895
1921
|
* Execute SQLite DB Connection Set
|
|
@@ -1904,7 +1930,7 @@ export interface ISQLiteDBConnection {
|
|
|
1904
1930
|
set: capSQLiteSet[],
|
|
1905
1931
|
transaction?: boolean,
|
|
1906
1932
|
returnMode?: string,
|
|
1907
|
-
isSQL92?: boolean
|
|
1933
|
+
isSQL92?: boolean,
|
|
1908
1934
|
): Promise<capSQLiteChanges>;
|
|
1909
1935
|
/**
|
|
1910
1936
|
* Check if a SQLite DB Connection exists
|
|
@@ -1978,7 +2004,7 @@ export interface ISQLiteDBConnection {
|
|
|
1978
2004
|
*/
|
|
1979
2005
|
executeTransaction(
|
|
1980
2006
|
txn: { statement: string; values?: any[] }[],
|
|
1981
|
-
isSQL92: boolean
|
|
2007
|
+
isSQL92: boolean,
|
|
1982
2008
|
): Promise<capSQLiteChanges>;
|
|
1983
2009
|
}
|
|
1984
2010
|
/**
|
|
@@ -1999,7 +2025,6 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
1999
2025
|
}
|
|
2000
2026
|
|
|
2001
2027
|
async open(): Promise<void> {
|
|
2002
|
-
|
|
2003
2028
|
try {
|
|
2004
2029
|
await this.sqlite.open({
|
|
2005
2030
|
database: this.dbName,
|
|
@@ -2023,8 +2048,9 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2023
2048
|
}
|
|
2024
2049
|
async beginTransaction(): Promise<capSQLiteChanges> {
|
|
2025
2050
|
try {
|
|
2026
|
-
const changes: capSQLiteChanges = await this.sqlite
|
|
2027
|
-
|
|
2051
|
+
const changes: capSQLiteChanges = await this.sqlite.beginTransaction({
|
|
2052
|
+
database: this.dbName,
|
|
2053
|
+
});
|
|
2028
2054
|
return Promise.resolve(changes);
|
|
2029
2055
|
} catch (err) {
|
|
2030
2056
|
return Promise.reject(err);
|
|
@@ -2032,8 +2058,9 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2032
2058
|
}
|
|
2033
2059
|
async commitTransaction(): Promise<capSQLiteChanges> {
|
|
2034
2060
|
try {
|
|
2035
|
-
const changes: capSQLiteChanges = await this.sqlite
|
|
2036
|
-
|
|
2061
|
+
const changes: capSQLiteChanges = await this.sqlite.commitTransaction({
|
|
2062
|
+
database: this.dbName,
|
|
2063
|
+
});
|
|
2037
2064
|
return Promise.resolve(changes);
|
|
2038
2065
|
} catch (err) {
|
|
2039
2066
|
return Promise.reject(err);
|
|
@@ -2041,22 +2068,24 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2041
2068
|
}
|
|
2042
2069
|
async rollbackTransaction(): Promise<capSQLiteChanges> {
|
|
2043
2070
|
try {
|
|
2044
|
-
const changes: capSQLiteChanges = await this.sqlite
|
|
2045
|
-
|
|
2071
|
+
const changes: capSQLiteChanges = await this.sqlite.rollbackTransaction({
|
|
2072
|
+
database: this.dbName,
|
|
2073
|
+
});
|
|
2046
2074
|
return Promise.resolve(changes);
|
|
2047
2075
|
} catch (err) {
|
|
2048
2076
|
return Promise.reject(err);
|
|
2049
2077
|
}
|
|
2050
|
-
}
|
|
2078
|
+
}
|
|
2051
2079
|
async isTransactionActive(): Promise<capSQLiteResult> {
|
|
2052
2080
|
try {
|
|
2053
|
-
const result: capSQLiteResult = await this.sqlite
|
|
2054
|
-
|
|
2081
|
+
const result: capSQLiteResult = await this.sqlite.isTransactionActive({
|
|
2082
|
+
database: this.dbName,
|
|
2083
|
+
});
|
|
2055
2084
|
return Promise.resolve(result);
|
|
2056
2085
|
} catch (err) {
|
|
2057
2086
|
return Promise.reject(err);
|
|
2058
2087
|
}
|
|
2059
|
-
}
|
|
2088
|
+
}
|
|
2060
2089
|
|
|
2061
2090
|
async loadExtension(path: string): Promise<void> {
|
|
2062
2091
|
try {
|
|
@@ -2119,7 +2148,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2119
2148
|
async execute(
|
|
2120
2149
|
statements: string,
|
|
2121
2150
|
transaction = true,
|
|
2122
|
-
isSQL92 = true
|
|
2151
|
+
isSQL92 = true,
|
|
2123
2152
|
): Promise<capSQLiteChanges> {
|
|
2124
2153
|
try {
|
|
2125
2154
|
if (!this.readonly) {
|
|
@@ -2128,7 +2157,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2128
2157
|
statements: statements,
|
|
2129
2158
|
transaction: transaction,
|
|
2130
2159
|
readonly: false,
|
|
2131
|
-
isSQL92: isSQL92
|
|
2160
|
+
isSQL92: isSQL92,
|
|
2132
2161
|
});
|
|
2133
2162
|
return Promise.resolve(res);
|
|
2134
2163
|
} else {
|
|
@@ -2138,7 +2167,11 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2138
2167
|
return Promise.reject(err);
|
|
2139
2168
|
}
|
|
2140
2169
|
}
|
|
2141
|
-
async query(
|
|
2170
|
+
async query(
|
|
2171
|
+
statement: string,
|
|
2172
|
+
values?: any[],
|
|
2173
|
+
isSQL92 = true,
|
|
2174
|
+
): Promise<DBSQLiteValues> {
|
|
2142
2175
|
let res: any;
|
|
2143
2176
|
try {
|
|
2144
2177
|
if (values && values.length > 0) {
|
|
@@ -2147,7 +2180,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2147
2180
|
statement: statement,
|
|
2148
2181
|
values: values,
|
|
2149
2182
|
readonly: this.readonly,
|
|
2150
|
-
isSql92
|
|
2183
|
+
isSql92: true,
|
|
2151
2184
|
});
|
|
2152
2185
|
} else {
|
|
2153
2186
|
res = await this.sqlite.query({
|
|
@@ -2155,7 +2188,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2155
2188
|
statement: statement,
|
|
2156
2189
|
values: [],
|
|
2157
2190
|
readonly: this.readonly,
|
|
2158
|
-
isSQL92: isSQL92
|
|
2191
|
+
isSQL92: isSQL92,
|
|
2159
2192
|
});
|
|
2160
2193
|
}
|
|
2161
2194
|
|
|
@@ -2171,7 +2204,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2171
2204
|
values?: any[],
|
|
2172
2205
|
transaction = true,
|
|
2173
2206
|
returnMode = 'no',
|
|
2174
|
-
isSQL92 = true
|
|
2207
|
+
isSQL92 = true,
|
|
2175
2208
|
): Promise<capSQLiteChanges> {
|
|
2176
2209
|
let res: any;
|
|
2177
2210
|
try {
|
|
@@ -2187,7 +2220,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2187
2220
|
transaction: transaction,
|
|
2188
2221
|
readonly: false,
|
|
2189
2222
|
returnMode: mRetMode,
|
|
2190
|
-
isSQL92: true
|
|
2223
|
+
isSQL92: true,
|
|
2191
2224
|
});
|
|
2192
2225
|
// }
|
|
2193
2226
|
} else {
|
|
@@ -2201,7 +2234,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2201
2234
|
transaction: transaction,
|
|
2202
2235
|
readonly: false,
|
|
2203
2236
|
returnMode: mRetMode,
|
|
2204
|
-
isSQL92: isSQL92
|
|
2237
|
+
isSQL92: isSQL92,
|
|
2205
2238
|
});
|
|
2206
2239
|
}
|
|
2207
2240
|
// reorder rows for ios
|
|
@@ -2218,7 +2251,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2218
2251
|
set: capSQLiteSet[],
|
|
2219
2252
|
transaction = true,
|
|
2220
2253
|
returnMode = 'no',
|
|
2221
|
-
isSQL92 = true
|
|
2254
|
+
isSQL92 = true,
|
|
2222
2255
|
): Promise<capSQLiteChanges> {
|
|
2223
2256
|
let res: any;
|
|
2224
2257
|
try {
|
|
@@ -2229,7 +2262,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2229
2262
|
transaction: transaction,
|
|
2230
2263
|
readonly: false,
|
|
2231
2264
|
returnMode: returnMode,
|
|
2232
|
-
isSQL92: isSQL92
|
|
2265
|
+
isSQL92: isSQL92,
|
|
2233
2266
|
});
|
|
2234
2267
|
// }
|
|
2235
2268
|
// reorder rows for ios
|
|
@@ -2366,21 +2399,23 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2366
2399
|
}
|
|
2367
2400
|
|
|
2368
2401
|
async executeTransaction(
|
|
2369
|
-
txn: { statement: string; values?: any[]}[],
|
|
2370
|
-
isSQL92 = true
|
|
2402
|
+
txn: { statement: string; values?: any[] }[],
|
|
2403
|
+
isSQL92 = true,
|
|
2371
2404
|
): Promise<capSQLiteChanges> {
|
|
2372
2405
|
let changes = 0;
|
|
2373
2406
|
let isActive = false;
|
|
2374
2407
|
if (!this.readonly) {
|
|
2375
2408
|
try {
|
|
2376
|
-
|
|
2377
|
-
database: this.dbName
|
|
2409
|
+
await this.sqlite.beginTransaction({
|
|
2410
|
+
database: this.dbName,
|
|
2378
2411
|
});
|
|
2379
2412
|
isActive = await this.sqlite.isTransactionActive({
|
|
2380
|
-
database: this.dbName
|
|
2413
|
+
database: this.dbName,
|
|
2381
2414
|
});
|
|
2382
|
-
if(!isActive) {
|
|
2383
|
-
return Promise.reject(
|
|
2415
|
+
if (!isActive) {
|
|
2416
|
+
return Promise.reject(
|
|
2417
|
+
'After Begin Transaction, no transaction active',
|
|
2418
|
+
);
|
|
2384
2419
|
}
|
|
2385
2420
|
} catch (err) {
|
|
2386
2421
|
return Promise.reject(err);
|
|
@@ -2398,7 +2433,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2398
2433
|
transaction: false,
|
|
2399
2434
|
readonly: false,
|
|
2400
2435
|
returnMode: retMode,
|
|
2401
|
-
isSQL92: isSQL92
|
|
2436
|
+
isSQL92: isSQL92,
|
|
2402
2437
|
});
|
|
2403
2438
|
if (ret.changes.changes <= 0) {
|
|
2404
2439
|
throw new Error('Error in transaction method run ');
|
|
@@ -2412,7 +2447,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2412
2447
|
readonly: false,
|
|
2413
2448
|
});
|
|
2414
2449
|
isActive = await this.sqlite.isTransactionActive({
|
|
2415
|
-
database: this.dbName
|
|
2450
|
+
database: this.dbName,
|
|
2416
2451
|
});
|
|
2417
2452
|
if (ret.changes.changes < 0) {
|
|
2418
2453
|
throw new Error('Error in transaction method execute ');
|
|
@@ -2421,33 +2456,32 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2421
2456
|
}
|
|
2422
2457
|
}
|
|
2423
2458
|
isActive = await this.sqlite.isTransactionActive({
|
|
2424
|
-
database: this.dbName
|
|
2459
|
+
database: this.dbName,
|
|
2425
2460
|
});
|
|
2426
|
-
if(isActive) {
|
|
2461
|
+
if (isActive) {
|
|
2427
2462
|
const retC = await this.sqlite.commitTransaction({
|
|
2428
|
-
database: this.dbName
|
|
2463
|
+
database: this.dbName,
|
|
2429
2464
|
});
|
|
2430
2465
|
changes += retC.changes.changes;
|
|
2431
2466
|
}
|
|
2432
|
-
const retChanges = {changes:{changes:changes}}
|
|
2467
|
+
const retChanges = { changes: { changes: changes } };
|
|
2433
2468
|
return Promise.resolve(retChanges);
|
|
2434
2469
|
} catch (err: any) {
|
|
2435
2470
|
const msg = err.message ? err.message : err;
|
|
2436
2471
|
isActive = await this.sqlite.isTransactionActive({
|
|
2437
|
-
database: this.dbName
|
|
2472
|
+
database: this.dbName,
|
|
2438
2473
|
});
|
|
2439
|
-
if(isActive) {
|
|
2474
|
+
if (isActive) {
|
|
2440
2475
|
await this.sqlite.rollbackTransaction({
|
|
2441
2476
|
database: this.dbName,
|
|
2442
2477
|
});
|
|
2443
2478
|
}
|
|
2444
2479
|
return Promise.reject(msg);
|
|
2445
2480
|
}
|
|
2446
|
-
|
|
2447
2481
|
} else {
|
|
2448
|
-
|
|
2482
|
+
return Promise.reject('not allowed in read-only mode');
|
|
2449
2483
|
}
|
|
2450
|
-
|
|
2484
|
+
}
|
|
2451
2485
|
private async reorderRows(res: any): Promise<any> {
|
|
2452
2486
|
const retRes: any = res;
|
|
2453
2487
|
if (res?.values && typeof res.values[0] === 'object') {
|
package/src/web.ts
CHANGED
|
@@ -217,7 +217,9 @@ export class CapacitorSQLiteWeb
|
|
|
217
217
|
throw new Error(`${err}`);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
async commitTransaction(
|
|
220
|
+
async commitTransaction(
|
|
221
|
+
options: capSQLiteOptions,
|
|
222
|
+
): Promise<capSQLiteChanges> {
|
|
221
223
|
this.ensureJeepSqliteIsAvailable();
|
|
222
224
|
this.ensureWebstoreIsOpen();
|
|
223
225
|
|
|
@@ -229,7 +231,9 @@ export class CapacitorSQLiteWeb
|
|
|
229
231
|
throw new Error(`${err}`);
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
|
-
async rollbackTransaction(
|
|
234
|
+
async rollbackTransaction(
|
|
235
|
+
options: capSQLiteOptions,
|
|
236
|
+
): Promise<capSQLiteChanges> {
|
|
233
237
|
this.ensureJeepSqliteIsAvailable();
|
|
234
238
|
this.ensureWebstoreIsOpen();
|
|
235
239
|
|
|
@@ -241,7 +245,9 @@ export class CapacitorSQLiteWeb
|
|
|
241
245
|
throw new Error(`${err}`);
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
|
-
async isTransactionActive(
|
|
248
|
+
async isTransactionActive(
|
|
249
|
+
options: capSQLiteOptions,
|
|
250
|
+
): Promise<capSQLiteResult> {
|
|
245
251
|
this.ensureJeepSqliteIsAvailable();
|
|
246
252
|
this.ensureWebstoreIsOpen();
|
|
247
253
|
|
|
@@ -252,7 +258,7 @@ export class CapacitorSQLiteWeb
|
|
|
252
258
|
} catch (err) {
|
|
253
259
|
throw new Error(`${err}`);
|
|
254
260
|
}
|
|
255
|
-
}
|
|
261
|
+
}
|
|
256
262
|
|
|
257
263
|
async getTableList(options: capSQLiteOptions): Promise<capSQLiteValues> {
|
|
258
264
|
this.ensureJeepSqliteIsAvailable();
|