cbl-ionic 0.2.5 → 1.0.0
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/CblIonic.podspec +1 -1
- package/README.md +12 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/cbl/js/kotiln/DatabaseManager.kt +19 -6
- package/android/src/main/java/com/couchbase/ionic/CblIonicPluginPlugin.kt +27 -17
- package/android/src/main/java/com/couchbase/ionic/ReplicatorHelper.kt +8 -4
- package/dist/esm/cblite-js/cblite/core-types.d.ts +5 -1
- package/dist/esm/cblite-js/cblite/src/collection.js +17 -17
- package/dist/esm/cblite-js/cblite/src/collection.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/database-logging.js +1 -1
- package/dist/esm/cblite-js/cblite/src/database-logging.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/database.d.ts +13 -2
- package/dist/esm/cblite-js/cblite/src/database.js +65 -40
- package/dist/esm/cblite-js/cblite/src/database.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/document.js +1 -1
- package/dist/esm/cblite-js/cblite/src/document.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/mutable-document.js +6 -1
- package/dist/esm/cblite-js/cblite/src/mutable-document.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/query.js +4 -4
- package/dist/esm/cblite-js/cblite/src/query.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/replicated-document.js +2 -2
- package/dist/esm/cblite-js/cblite/src/replicated-document.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/replicator-configuration.d.ts +1 -1
- package/dist/esm/cblite-js/cblite/src/replicator-configuration.js +9 -3
- package/dist/esm/cblite-js/cblite/src/replicator-configuration.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/replicator.js +6 -3
- package/dist/esm/cblite-js/cblite/src/replicator.js.map +1 -1
- package/dist/esm/cblite-js/cblite/src/scope.js +2 -2
- package/dist/esm/cblite-js/cblite/src/scope.js.map +1 -1
- package/dist/esm/couchbase-lite/capacitor-engine.d.ts +4 -1
- package/dist/esm/couchbase-lite/capacitor-engine.js.map +1 -1
- package/dist/plugin.cjs.js +113 -74
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +113 -74
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CblIonicPlugin.swift +5 -3
- package/ios/Plugin/cbl-js-swift/CollectionManager.swift +2 -3
- package/ios/Plugin/cbl-js-swift/DatabaseManager.swift +29 -13
- package/ios/Plugin/cbl-js-swift/FileSystemHelper.swift +0 -2
- package/ios/Plugin/cbl-js-swift/IndexHelper.swift +0 -2
- package/ios/Plugin/cbl-js-swift/LoggingManager.swift +0 -2
- package/ios/Plugin/cbl-js-swift/MapHelper.swift +0 -2
- package/ios/Plugin/cbl-js-swift/QueryHelper.swift +0 -2
- package/ios/Plugin/cbl-js-swift/README.md +12 -0
- package/ios/Plugin/cbl-js-swift/ReplicatorHelper.swift +0 -2
- package/ios/Plugin/cbl-js-swift/ReplicatorManager.swift +0 -2
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -74,7 +74,13 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
74
74
|
this.headers = undefined;
|
|
75
75
|
this.pinnedServerCertificate = undefined;
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Add a collection used for the replication with an optional collection configuration. If the collection has
|
|
79
|
+
* been added before, the previous added and its configuration if specified will be replaced. If the config is omitted or a null or undefined configuration is specified, a default empty configuration will be applied.
|
|
80
|
+
*
|
|
81
|
+
* @function
|
|
82
|
+
*/
|
|
83
|
+
// eslint-disable-next-line
|
|
78
84
|
addCollection(collection, config) {
|
|
79
85
|
const cols = [];
|
|
80
86
|
cols.push(collection);
|
|
@@ -527,10 +533,10 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
527
533
|
for (const [collections, _] of this.collections) {
|
|
528
534
|
for (const collection of collections) {
|
|
529
535
|
if (databaseName === null && scopeName === null) {
|
|
530
|
-
databaseName = collection.database.
|
|
536
|
+
databaseName = collection.database.getUniqueName();
|
|
531
537
|
scopeName = collection.scope.name;
|
|
532
538
|
}
|
|
533
|
-
else if (collection.database.
|
|
539
|
+
else if (collection.database.getUniqueName() !== databaseName ||
|
|
534
540
|
collection.scope.name !== scopeName) {
|
|
535
541
|
return false;
|
|
536
542
|
}
|
|
@@ -831,7 +837,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
831
837
|
*/
|
|
832
838
|
async collections() {
|
|
833
839
|
const results = await this._engine.collection_GetCollections({
|
|
834
|
-
name: this.database.
|
|
840
|
+
name: this.database.getUniqueName(),
|
|
835
841
|
scopeName: this.name,
|
|
836
842
|
});
|
|
837
843
|
return results.collections;
|
|
@@ -844,7 +850,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
844
850
|
*/
|
|
845
851
|
async collection(collectionName) {
|
|
846
852
|
return this._engine.collection_GetCollection({
|
|
847
|
-
name: this.database.
|
|
853
|
+
name: this.database.getUniqueName(),
|
|
848
854
|
collectionName: collectionName,
|
|
849
855
|
scopeName: this.name,
|
|
850
856
|
});
|
|
@@ -941,7 +947,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
941
947
|
key: key,
|
|
942
948
|
collectionName: this.collection.name,
|
|
943
949
|
scopeName: this.collection.scope.name,
|
|
944
|
-
name: this.collection.scope.database.
|
|
950
|
+
name: this.collection.scope.database.getUniqueName(),
|
|
945
951
|
});
|
|
946
952
|
return data.data;
|
|
947
953
|
}
|
|
@@ -1209,7 +1215,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1209
1215
|
const token = this.uuid();
|
|
1210
1216
|
if (!this._didStartListener) {
|
|
1211
1217
|
await this._engine.collection_AddChangeListener({
|
|
1212
|
-
name: this.scope.database.
|
|
1218
|
+
name: this.scope.database.getUniqueName(),
|
|
1213
1219
|
scopeName: this.scope.name,
|
|
1214
1220
|
collectionName: this.name,
|
|
1215
1221
|
changeListenerToken: token,
|
|
@@ -1236,7 +1242,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1236
1242
|
if (!this._didStartDocumentListener.has(documentId) &&
|
|
1237
1243
|
!this._documentChangeListener[documentId]) {
|
|
1238
1244
|
await this._engine.collection_AddDocumentChangeListener({
|
|
1239
|
-
name: this.scope.database.
|
|
1245
|
+
name: this.scope.database.getUniqueName(),
|
|
1240
1246
|
scopeName: this.scope.name,
|
|
1241
1247
|
collectionName: this.name,
|
|
1242
1248
|
changeListenerToken: token,
|
|
@@ -1262,7 +1268,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1262
1268
|
*/
|
|
1263
1269
|
count() {
|
|
1264
1270
|
return this._engine.collection_GetCount({
|
|
1265
|
-
name: this.scope.database.
|
|
1271
|
+
name: this.scope.database.getUniqueName(),
|
|
1266
1272
|
scopeName: this.scope.name,
|
|
1267
1273
|
collectionName: this.name,
|
|
1268
1274
|
});
|
|
@@ -1274,7 +1280,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1274
1280
|
*/
|
|
1275
1281
|
createIndex(indexName, index) {
|
|
1276
1282
|
return this._engine.collection_CreateIndex({
|
|
1277
|
-
name: this.scope.database.
|
|
1283
|
+
name: this.scope.database.getUniqueName(),
|
|
1278
1284
|
scopeName: this.scope.name,
|
|
1279
1285
|
collectionName: this.name,
|
|
1280
1286
|
indexName: indexName,
|
|
@@ -1297,7 +1303,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1297
1303
|
deleteDocument(document, concurrencyControl = null) {
|
|
1298
1304
|
const id = document.getId();
|
|
1299
1305
|
return this._engine.collection_DeleteDocument({
|
|
1300
|
-
name: this.scope.database.
|
|
1306
|
+
name: this.scope.database.getUniqueName(),
|
|
1301
1307
|
scopeName: this.scope.name,
|
|
1302
1308
|
collectionName: this.name,
|
|
1303
1309
|
docId: id,
|
|
@@ -1311,7 +1317,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1311
1317
|
*/
|
|
1312
1318
|
deleteIndex(indexName) {
|
|
1313
1319
|
return this._engine.collection_DeleteIndex({
|
|
1314
|
-
name: this.scope.database.
|
|
1320
|
+
name: this.scope.database.getUniqueName(),
|
|
1315
1321
|
scopeName: this.scope.name,
|
|
1316
1322
|
collectionName: this.name,
|
|
1317
1323
|
indexName: indexName,
|
|
@@ -1327,7 +1333,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1327
1333
|
async document(id) {
|
|
1328
1334
|
const docJson = await this._engine.collection_GetDocument({
|
|
1329
1335
|
docId: id,
|
|
1330
|
-
name: this.scope.database.
|
|
1336
|
+
name: this.scope.database.getUniqueName(),
|
|
1331
1337
|
scopeName: this.scope.name,
|
|
1332
1338
|
collectionName: this.name,
|
|
1333
1339
|
});
|
|
@@ -1367,11 +1373,11 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1367
1373
|
async getDocumentExpiration(id) {
|
|
1368
1374
|
const date = await this._engine.collection_GetDocumentExpiration({
|
|
1369
1375
|
docId: id,
|
|
1370
|
-
name: this.scope.database.
|
|
1376
|
+
name: this.scope.database.getUniqueName(),
|
|
1371
1377
|
scopeName: this.scope.name,
|
|
1372
1378
|
collectionName: this.name,
|
|
1373
1379
|
});
|
|
1374
|
-
if (date
|
|
1380
|
+
if (!!date && date?.date) {
|
|
1375
1381
|
return date.date;
|
|
1376
1382
|
}
|
|
1377
1383
|
else {
|
|
@@ -1393,7 +1399,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1393
1399
|
*/
|
|
1394
1400
|
async indexes() {
|
|
1395
1401
|
const indexes = await this._engine.collection_GetIndexes({
|
|
1396
|
-
name: this.scope.database.
|
|
1402
|
+
name: this.scope.database.getUniqueName(),
|
|
1397
1403
|
scopeName: this.scope.name,
|
|
1398
1404
|
collectionName: this.name,
|
|
1399
1405
|
});
|
|
@@ -1431,7 +1437,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1431
1437
|
*/
|
|
1432
1438
|
purge(document) {
|
|
1433
1439
|
return this._engine.collection_PurgeDocument({
|
|
1434
|
-
name: this.database.
|
|
1440
|
+
name: this.database.getUniqueName(),
|
|
1435
1441
|
scopeName: this.scope.name,
|
|
1436
1442
|
collectionName: this.name,
|
|
1437
1443
|
docId: document.getId(),
|
|
@@ -1447,7 +1453,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1447
1453
|
*/
|
|
1448
1454
|
purgeById(documentId) {
|
|
1449
1455
|
return this._engine.collection_PurgeDocument({
|
|
1450
|
-
name: this.database.
|
|
1456
|
+
name: this.database.getUniqueName(),
|
|
1451
1457
|
scopeName: this.scope.name,
|
|
1452
1458
|
collectionName: this.name,
|
|
1453
1459
|
docId: documentId,
|
|
@@ -1462,7 +1468,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1462
1468
|
*/
|
|
1463
1469
|
async removeChangeListener(token) {
|
|
1464
1470
|
await this._engine.collection_RemoveChangeListener({
|
|
1465
|
-
name: this.database.
|
|
1471
|
+
name: this.database.getUniqueName(),
|
|
1466
1472
|
scopeName: this.scope.name,
|
|
1467
1473
|
collectionName: this.name,
|
|
1468
1474
|
changeListenerToken: token,
|
|
@@ -1477,7 +1483,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1477
1483
|
*/
|
|
1478
1484
|
async removeDocumentChangeListener(token) {
|
|
1479
1485
|
await this._engine.collection_RemoveDocumentChangeListener({
|
|
1480
|
-
name: this.database.
|
|
1486
|
+
name: this.database.getUniqueName(),
|
|
1481
1487
|
scopeName: this.scope.name,
|
|
1482
1488
|
collectionName: this.name,
|
|
1483
1489
|
changeListenerToken: token,
|
|
@@ -1503,7 +1509,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1503
1509
|
document: documentString,
|
|
1504
1510
|
blobs: blobString,
|
|
1505
1511
|
concurrencyControl: concurrencyControl,
|
|
1506
|
-
name: this.scope.database.
|
|
1512
|
+
name: this.scope.database.getUniqueName(),
|
|
1507
1513
|
scopeName: this.scope.name,
|
|
1508
1514
|
collectionName: this.name,
|
|
1509
1515
|
});
|
|
@@ -1515,7 +1521,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1515
1521
|
async setDocumentExpiration(id, expiration) {
|
|
1516
1522
|
await this._engine.collection_SetDocumentExpiration({
|
|
1517
1523
|
docId: id,
|
|
1518
|
-
name: this.database.
|
|
1524
|
+
name: this.database.getUniqueName(),
|
|
1519
1525
|
scopeName: this.scope.name,
|
|
1520
1526
|
collectionName: this.name,
|
|
1521
1527
|
expiration: expiration,
|
|
@@ -1525,7 +1531,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1525
1531
|
return {
|
|
1526
1532
|
name: this.name,
|
|
1527
1533
|
scopeName: this.scope.name,
|
|
1528
|
-
databaseName: this.database.
|
|
1534
|
+
databaseName: this.database.getUniqueName(),
|
|
1529
1535
|
};
|
|
1530
1536
|
}
|
|
1531
1537
|
uuid() {
|
|
@@ -1638,7 +1644,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1638
1644
|
}
|
|
1639
1645
|
setFileConfig(config) {
|
|
1640
1646
|
return this.database.getEngine().database_SetFileLoggingConfig({
|
|
1641
|
-
name: this.database.
|
|
1647
|
+
name: this.database.getUniqueName(),
|
|
1642
1648
|
config: config,
|
|
1643
1649
|
});
|
|
1644
1650
|
}
|
|
@@ -1764,7 +1770,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1764
1770
|
const token = this._engine.getUUID();
|
|
1765
1771
|
if (!this._didStartQueryListener) {
|
|
1766
1772
|
await this._engine.query_AddChangeListener({
|
|
1767
|
-
name: this._database.
|
|
1773
|
+
name: this._database.getUniqueName(),
|
|
1768
1774
|
query: this._queryString,
|
|
1769
1775
|
parameters: this.parameters,
|
|
1770
1776
|
changeListenerToken: token,
|
|
@@ -1801,7 +1807,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1801
1807
|
this.parameters = new Parameters();
|
|
1802
1808
|
}
|
|
1803
1809
|
const queryResults = await this._database.getEngine().query_Execute({
|
|
1804
|
-
name: this._database.
|
|
1810
|
+
name: this._database.getUniqueName(),
|
|
1805
1811
|
query: this._queryString,
|
|
1806
1812
|
parameters: this.parameters.get(),
|
|
1807
1813
|
});
|
|
@@ -1824,7 +1830,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1824
1830
|
this.parameters = new Parameters();
|
|
1825
1831
|
}
|
|
1826
1832
|
const queryResults = await this._database.getEngine().query_Explain({
|
|
1827
|
-
name: this._database.
|
|
1833
|
+
name: this._database.getUniqueName(),
|
|
1828
1834
|
query: this._queryString,
|
|
1829
1835
|
parameters: this.parameters.get(),
|
|
1830
1836
|
});
|
|
@@ -1864,7 +1870,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1864
1870
|
async removeChangeListener(token) {
|
|
1865
1871
|
await this._database.getEngine().query_RemoveChangeListener({
|
|
1866
1872
|
changeListenerToken: token,
|
|
1867
|
-
name: this._database.
|
|
1873
|
+
name: this._database.getUniqueName(),
|
|
1868
1874
|
});
|
|
1869
1875
|
}
|
|
1870
1876
|
setDatabase(database) {
|
|
@@ -1935,9 +1941,12 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1935
1941
|
// eslint-disable-next-line
|
|
1936
1942
|
_databaseName,
|
|
1937
1943
|
// eslint-disable-next-line
|
|
1938
|
-
_databaseConfig = null
|
|
1944
|
+
_databaseConfig = null,
|
|
1945
|
+
// eslint-disable-next-line
|
|
1946
|
+
_databaseUniqueName = null) {
|
|
1939
1947
|
this._databaseName = _databaseName;
|
|
1940
1948
|
this._databaseConfig = _databaseConfig;
|
|
1949
|
+
this._databaseUniqueName = _databaseUniqueName;
|
|
1941
1950
|
this._isClosed = false;
|
|
1942
1951
|
this._engine = EngineLocator.getEngine(EngineLocator.key);
|
|
1943
1952
|
this.log = new DatabaseLogging(this);
|
|
@@ -1947,16 +1956,19 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1947
1956
|
}
|
|
1948
1957
|
/**
|
|
1949
1958
|
* Open a database with the given name and configuration.
|
|
1959
|
+
* Returns the unique internal name of the database which consists of the provided name and nanoId.
|
|
1960
|
+
* The unique name is used to allow multiple instances of the same database to be opened at the same time.
|
|
1950
1961
|
*
|
|
1951
1962
|
* @function
|
|
1952
1963
|
*/
|
|
1953
|
-
open() {
|
|
1954
|
-
const
|
|
1964
|
+
async open() {
|
|
1965
|
+
const { databaseUniqueName } = await this._engine.database_Open({
|
|
1955
1966
|
name: this._databaseName,
|
|
1956
1967
|
config: this._databaseConfig,
|
|
1957
1968
|
});
|
|
1969
|
+
this._databaseUniqueName = databaseUniqueName;
|
|
1958
1970
|
this._isClosed = false;
|
|
1959
|
-
return
|
|
1971
|
+
return databaseUniqueName;
|
|
1960
1972
|
}
|
|
1961
1973
|
/**
|
|
1962
1974
|
* Changes the database’s encryption key, or removes
|
|
@@ -1966,7 +1978,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1966
1978
|
*/
|
|
1967
1979
|
async changeEncryptionKey(newKey) {
|
|
1968
1980
|
await this._engine.database_ChangeEncryptionKey({
|
|
1969
|
-
name: this.
|
|
1981
|
+
name: this._databaseUniqueName,
|
|
1970
1982
|
newKey: newKey,
|
|
1971
1983
|
});
|
|
1972
1984
|
this._databaseConfig.setEncryptionKey(newKey);
|
|
@@ -1977,7 +1989,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1977
1989
|
* @function
|
|
1978
1990
|
*/
|
|
1979
1991
|
close() {
|
|
1980
|
-
const result = this._engine.database_Close({ name: this.
|
|
1992
|
+
const result = this._engine.database_Close({ name: this._databaseUniqueName });
|
|
1981
1993
|
this._isClosed = true;
|
|
1982
1994
|
return result;
|
|
1983
1995
|
}
|
|
@@ -1988,7 +2000,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1988
2000
|
*/
|
|
1989
2001
|
compact() {
|
|
1990
2002
|
const args = {
|
|
1991
|
-
name: this.
|
|
2003
|
+
name: this._databaseUniqueName,
|
|
1992
2004
|
maintenanceType: exports.MaintenanceType.COMPACT,
|
|
1993
2005
|
};
|
|
1994
2006
|
return this._engine.database_PerformMaintenance(args);
|
|
@@ -1999,7 +2011,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
1999
2011
|
* @function
|
|
2000
2012
|
*/
|
|
2001
2013
|
performMaintenance(maintenanceType) {
|
|
2002
|
-
const args = { name: this.
|
|
2014
|
+
const args = { name: this._databaseUniqueName, maintenanceType: maintenanceType };
|
|
2003
2015
|
return this._engine.database_PerformMaintenance(args);
|
|
2004
2016
|
}
|
|
2005
2017
|
/**
|
|
@@ -2009,7 +2021,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2009
2021
|
*/
|
|
2010
2022
|
copy(path, name, config) {
|
|
2011
2023
|
return this._engine.database_Copy({
|
|
2012
|
-
name: this.
|
|
2024
|
+
name: this._databaseUniqueName,
|
|
2013
2025
|
path: path,
|
|
2014
2026
|
newName: name,
|
|
2015
2027
|
config: config,
|
|
@@ -2024,7 +2036,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2024
2036
|
if (this._isClosed) {
|
|
2025
2037
|
throw new Error('Cannot delete a closed database using this API. Open the database first.');
|
|
2026
2038
|
}
|
|
2027
|
-
return this._engine.database_Delete({ name: this.
|
|
2039
|
+
return this._engine.database_Delete({ name: this._databaseUniqueName });
|
|
2028
2040
|
}
|
|
2029
2041
|
/**
|
|
2030
2042
|
* Deletes a database.
|
|
@@ -2045,7 +2057,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2045
2057
|
* @function
|
|
2046
2058
|
*/
|
|
2047
2059
|
async getPath() {
|
|
2048
|
-
return (await this._engine.database_GetPath({ name: this.
|
|
2060
|
+
return (await this._engine.database_GetPath({ name: this._databaseUniqueName }))
|
|
2049
2061
|
.path;
|
|
2050
2062
|
}
|
|
2051
2063
|
/**
|
|
@@ -2070,6 +2082,16 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2070
2082
|
getName() {
|
|
2071
2083
|
return this._databaseName;
|
|
2072
2084
|
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Return the database unique name.
|
|
2087
|
+
* Unique name is generated by adding a nanoId to the database name.
|
|
2088
|
+
* This is used to allow multiple instances of the same database to be opened at the same time.
|
|
2089
|
+
*
|
|
2090
|
+
* @function
|
|
2091
|
+
*/
|
|
2092
|
+
getUniqueName() {
|
|
2093
|
+
return this._databaseUniqueName;
|
|
2094
|
+
}
|
|
2073
2095
|
/**
|
|
2074
2096
|
* Returns a READONLY config object which will throw a runtime exception when any setter methods are called.
|
|
2075
2097
|
*
|
|
@@ -2115,7 +2137,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2115
2137
|
*/
|
|
2116
2138
|
async defaultScope() {
|
|
2117
2139
|
const scope = await this._engine.scope_GetDefault({
|
|
2118
|
-
name: this.
|
|
2140
|
+
name: this._databaseUniqueName,
|
|
2119
2141
|
});
|
|
2120
2142
|
return new Scope(scope.name, this);
|
|
2121
2143
|
}
|
|
@@ -2127,7 +2149,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2127
2149
|
async scope(scopeName) {
|
|
2128
2150
|
try {
|
|
2129
2151
|
const scope = await this._engine.scope_GetScope({
|
|
2130
|
-
name: this.
|
|
2152
|
+
name: this._databaseUniqueName,
|
|
2131
2153
|
scopeName: scopeName,
|
|
2132
2154
|
});
|
|
2133
2155
|
return new Scope(scope.name, this);
|
|
@@ -2143,7 +2165,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2143
2165
|
*/
|
|
2144
2166
|
async scopes() {
|
|
2145
2167
|
const results = await this._engine.scope_GetScopes({
|
|
2146
|
-
name: this.
|
|
2168
|
+
name: this._databaseUniqueName,
|
|
2147
2169
|
});
|
|
2148
2170
|
const scopes = [];
|
|
2149
2171
|
for (const scope of results.scopes) {
|
|
@@ -2158,7 +2180,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2158
2180
|
*/
|
|
2159
2181
|
async defaultCollection() {
|
|
2160
2182
|
const col = await this._engine.collection_GetDefault({
|
|
2161
|
-
name: this.
|
|
2183
|
+
name: this._databaseUniqueName,
|
|
2162
2184
|
});
|
|
2163
2185
|
const scope = new Scope(col.scope.name, this);
|
|
2164
2186
|
return new Collection(col.name, scope, this);
|
|
@@ -2168,21 +2190,21 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2168
2190
|
let col;
|
|
2169
2191
|
if (typeof scopeOrName === 'string') {
|
|
2170
2192
|
col = await this._engine.collection_GetCollection({
|
|
2171
|
-
name: this.
|
|
2193
|
+
name: this._databaseUniqueName,
|
|
2172
2194
|
collectionName: collectionName,
|
|
2173
2195
|
scopeName: scopeOrName,
|
|
2174
2196
|
});
|
|
2175
2197
|
}
|
|
2176
2198
|
else if (scopeOrName instanceof Scope) {
|
|
2177
2199
|
col = await this._engine.collection_GetCollection({
|
|
2178
|
-
name: this.
|
|
2200
|
+
name: this._databaseUniqueName,
|
|
2179
2201
|
collectionName: collectionName,
|
|
2180
2202
|
scopeName: scopeOrName.name,
|
|
2181
2203
|
});
|
|
2182
2204
|
}
|
|
2183
2205
|
else {
|
|
2184
2206
|
col = await this._engine.collection_GetCollection({
|
|
2185
|
-
name: this.
|
|
2207
|
+
name: this._databaseUniqueName,
|
|
2186
2208
|
collectionName: collectionName,
|
|
2187
2209
|
scopeName: Database.defaultScopeName,
|
|
2188
2210
|
});
|
|
@@ -2196,19 +2218,19 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2196
2218
|
let colResults;
|
|
2197
2219
|
if (typeof scopeOrName === 'string') {
|
|
2198
2220
|
colResults = await this._engine.collection_GetCollections({
|
|
2199
|
-
name: this.
|
|
2221
|
+
name: this._databaseUniqueName,
|
|
2200
2222
|
scopeName: scopeOrName,
|
|
2201
2223
|
});
|
|
2202
2224
|
}
|
|
2203
2225
|
else if (scopeOrName instanceof Scope) {
|
|
2204
2226
|
colResults = await this._engine.collection_GetCollections({
|
|
2205
|
-
name: this.
|
|
2227
|
+
name: this._databaseUniqueName,
|
|
2206
2228
|
scopeName: scopeOrName.name,
|
|
2207
2229
|
});
|
|
2208
2230
|
}
|
|
2209
2231
|
else {
|
|
2210
2232
|
colResults = await this._engine.collection_GetCollections({
|
|
2211
|
-
name: this.
|
|
2233
|
+
name: this._databaseUniqueName,
|
|
2212
2234
|
scopeName: Database.defaultScopeName,
|
|
2213
2235
|
});
|
|
2214
2236
|
}
|
|
@@ -2223,21 +2245,21 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2223
2245
|
let col;
|
|
2224
2246
|
if (typeof scopeOrName === 'string') {
|
|
2225
2247
|
col = await this._engine.collection_CreateCollection({
|
|
2226
|
-
name: this.
|
|
2248
|
+
name: this._databaseUniqueName,
|
|
2227
2249
|
collectionName: collectionName,
|
|
2228
2250
|
scopeName: scopeOrName,
|
|
2229
2251
|
});
|
|
2230
2252
|
}
|
|
2231
2253
|
else if (scopeOrName instanceof Scope) {
|
|
2232
2254
|
col = await this._engine.collection_CreateCollection({
|
|
2233
|
-
name: this.
|
|
2255
|
+
name: this._databaseUniqueName,
|
|
2234
2256
|
collectionName: collectionName,
|
|
2235
2257
|
scopeName: scopeOrName.name,
|
|
2236
2258
|
});
|
|
2237
2259
|
}
|
|
2238
2260
|
else {
|
|
2239
2261
|
col = await this._engine.collection_CreateCollection({
|
|
2240
|
-
name: this.
|
|
2262
|
+
name: this._databaseUniqueName,
|
|
2241
2263
|
collectionName: collectionName,
|
|
2242
2264
|
scopeName: Database.defaultScopeName,
|
|
2243
2265
|
});
|
|
@@ -2249,14 +2271,14 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2249
2271
|
deleteCollection(collectionOrName, scopeName) {
|
|
2250
2272
|
if (typeof collectionOrName === 'string' && scopeName !== undefined) {
|
|
2251
2273
|
return this._engine.collection_DeleteCollection({
|
|
2252
|
-
name: this.
|
|
2274
|
+
name: this._databaseUniqueName,
|
|
2253
2275
|
collectionName: collectionOrName,
|
|
2254
2276
|
scopeName: scopeName,
|
|
2255
2277
|
});
|
|
2256
2278
|
}
|
|
2257
2279
|
else if (collectionOrName instanceof Collection) {
|
|
2258
2280
|
return this._engine.collection_DeleteCollection({
|
|
2259
|
-
name: this.
|
|
2281
|
+
name: this._databaseUniqueName,
|
|
2260
2282
|
collectionName: collectionOrName.name,
|
|
2261
2283
|
scopeName: collectionOrName.scope.name,
|
|
2262
2284
|
});
|
|
@@ -2273,7 +2295,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2273
2295
|
deleteDocument(document, concurrencyControl = null) {
|
|
2274
2296
|
const id = document.getId();
|
|
2275
2297
|
return this._engine.database_DeleteDocument({
|
|
2276
|
-
name: this.
|
|
2298
|
+
name: this._databaseUniqueName,
|
|
2277
2299
|
docId: id,
|
|
2278
2300
|
concurrencyControl: concurrencyControl,
|
|
2279
2301
|
});
|
|
@@ -2285,7 +2307,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2285
2307
|
*/
|
|
2286
2308
|
purgeDocument(document) {
|
|
2287
2309
|
return this._engine.database_PurgeDocument({
|
|
2288
|
-
name: this.
|
|
2310
|
+
name: this._databaseUniqueName,
|
|
2289
2311
|
docId: document.getId(),
|
|
2290
2312
|
});
|
|
2291
2313
|
}
|
|
@@ -2296,7 +2318,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2296
2318
|
*/
|
|
2297
2319
|
async getCount() {
|
|
2298
2320
|
const count = await this._engine.database_GetCount({
|
|
2299
|
-
name: this.
|
|
2321
|
+
name: this._databaseUniqueName,
|
|
2300
2322
|
});
|
|
2301
2323
|
return Promise.resolve(count.count);
|
|
2302
2324
|
}
|
|
@@ -2306,18 +2328,24 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2306
2328
|
* @function
|
|
2307
2329
|
*/
|
|
2308
2330
|
async getDocument(id) {
|
|
2309
|
-
const docJson = await this._engine.
|
|
2310
|
-
name: this._databaseName,
|
|
2331
|
+
const docJson = await this._engine.collection_GetDocument({
|
|
2311
2332
|
docId: id,
|
|
2333
|
+
name: this._databaseUniqueName,
|
|
2334
|
+
scopeName: "_default",
|
|
2335
|
+
collectionName: "_default",
|
|
2312
2336
|
});
|
|
2313
|
-
|
|
2337
|
+
const collection = await this.defaultCollection();
|
|
2338
|
+
// @ts-expect-error - _id is used in getId()
|
|
2339
|
+
if (docJson && docJson._id) {
|
|
2314
2340
|
// @ts-expect-error - _data is used in getData()
|
|
2315
2341
|
const data = docJson._data;
|
|
2316
2342
|
// @ts-expect-error - _sequence is used in getSequence()
|
|
2317
2343
|
const sequence = docJson._sequence;
|
|
2318
2344
|
// @ts-expect-error _id exists in documents
|
|
2319
2345
|
const retId = docJson._id;
|
|
2320
|
-
|
|
2346
|
+
// @ts-expect-error - _revId is used in getRevisionID()
|
|
2347
|
+
const revisionID = docJson._revId;
|
|
2348
|
+
return Promise.resolve(new Document(retId, sequence, revisionID, collection, data));
|
|
2321
2349
|
}
|
|
2322
2350
|
else {
|
|
2323
2351
|
return Promise.resolve(null);
|
|
@@ -2329,15 +2357,18 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2329
2357
|
* @function
|
|
2330
2358
|
*/
|
|
2331
2359
|
async save(document, concurrencyControl = null) {
|
|
2332
|
-
const ret = await this._engine.
|
|
2333
|
-
name: this._databaseName,
|
|
2360
|
+
const ret = await this._engine.collection_Save({
|
|
2334
2361
|
id: document.getId(),
|
|
2335
2362
|
document: document.toJsonString(),
|
|
2336
2363
|
blobs: document.blobsToJsonString(),
|
|
2337
2364
|
concurrencyControl: concurrencyControl,
|
|
2365
|
+
name: this._databaseUniqueName,
|
|
2366
|
+
scopeName: "_default",
|
|
2367
|
+
collectionName: "_default",
|
|
2338
2368
|
});
|
|
2339
|
-
|
|
2340
|
-
document.
|
|
2369
|
+
document.setId(ret._id);
|
|
2370
|
+
document.setRevisionID(ret._revId);
|
|
2371
|
+
document.setSequence(ret._sequence);
|
|
2341
2372
|
}
|
|
2342
2373
|
/**
|
|
2343
2374
|
* @deprecated createIndex is deprecated. Use Collection createIndex instead.
|
|
@@ -2346,7 +2377,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2346
2377
|
*/
|
|
2347
2378
|
createIndex(indexName, index) {
|
|
2348
2379
|
return this._engine.database_CreateIndex({
|
|
2349
|
-
name: this.
|
|
2380
|
+
name: this._databaseUniqueName,
|
|
2350
2381
|
indexName: indexName,
|
|
2351
2382
|
index: index.toJson(),
|
|
2352
2383
|
});
|
|
@@ -2358,7 +2389,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2358
2389
|
*/
|
|
2359
2390
|
async getIndexes() {
|
|
2360
2391
|
return (await this._engine.database_GetIndexes({
|
|
2361
|
-
name: this.
|
|
2392
|
+
name: this._databaseUniqueName,
|
|
2362
2393
|
})).indexes;
|
|
2363
2394
|
}
|
|
2364
2395
|
/**
|
|
@@ -2368,7 +2399,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2368
2399
|
*/
|
|
2369
2400
|
deleteIndex(indexName) {
|
|
2370
2401
|
return this._engine.database_DeleteIndex({
|
|
2371
|
-
name: this.
|
|
2402
|
+
name: this._databaseUniqueName,
|
|
2372
2403
|
indexName: indexName,
|
|
2373
2404
|
});
|
|
2374
2405
|
}
|
|
@@ -2432,8 +2463,8 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
2432
2463
|
if (object.id === null) {
|
|
2433
2464
|
throw 'document id cannot be null';
|
|
2434
2465
|
}
|
|
2435
|
-
if (object.error
|
|
2436
|
-
if (object.error.message
|
|
2466
|
+
if (object.error) {
|
|
2467
|
+
if (!object.error.message) {
|
|
2437
2468
|
throw 'document error is incomplete';
|
|
2438
2469
|
}
|
|
2439
2470
|
}
|
|
@@ -3096,7 +3127,12 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
3096
3127
|
}
|
|
3097
3128
|
else if (arguments.length === 1) {
|
|
3098
3129
|
// Just ID
|
|
3099
|
-
|
|
3130
|
+
if (id === null || id.length === 0) {
|
|
3131
|
+
super(null, null, null, null, {});
|
|
3132
|
+
}
|
|
3133
|
+
else {
|
|
3134
|
+
super(id, null, null, null, {});
|
|
3135
|
+
}
|
|
3100
3136
|
}
|
|
3101
3137
|
else if (arguments.length === 2 && typeof sequenceNoOrData === 'object') {
|
|
3102
3138
|
// ID and data
|
|
@@ -3688,7 +3724,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
3688
3724
|
}
|
|
3689
3725
|
}
|
|
3690
3726
|
async addDocumentChangeListener(listener) {
|
|
3691
|
-
const token = this._engine.getUUID();
|
|
3727
|
+
const token = this._engine.getUUID() + "_doc";
|
|
3692
3728
|
this._documentChangeListener.set(token, listener);
|
|
3693
3729
|
await this._engine.replicator_AddDocumentChangeListener({
|
|
3694
3730
|
replicatorId: this._replicatorId,
|
|
@@ -3775,7 +3811,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
3775
3811
|
replicatorId: this._replicatorId,
|
|
3776
3812
|
collectionName: collection.name,
|
|
3777
3813
|
scopeName: collection.scope.name,
|
|
3778
|
-
name: collection.database.
|
|
3814
|
+
name: collection.database.getUniqueName(),
|
|
3779
3815
|
});
|
|
3780
3816
|
}
|
|
3781
3817
|
/**
|
|
@@ -3793,7 +3829,7 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
3793
3829
|
documentId: documentId,
|
|
3794
3830
|
collectionName: collection.name,
|
|
3795
3831
|
scopeName: collection.scope.name,
|
|
3796
|
-
name: collection.database.
|
|
3832
|
+
name: collection.database.getUniqueName(),
|
|
3797
3833
|
});
|
|
3798
3834
|
}
|
|
3799
3835
|
notifyDocumentChange(data, token) {
|
|
@@ -3828,6 +3864,9 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
|
|
|
3828
3864
|
* @function
|
|
3829
3865
|
*/
|
|
3830
3866
|
async removeChangeListener(token) {
|
|
3867
|
+
if (this._documentChangeListener.has(token)) {
|
|
3868
|
+
this._documentChangeListener.delete(token);
|
|
3869
|
+
}
|
|
3831
3870
|
await this._engine.replicator_RemoveChangeListener({
|
|
3832
3871
|
replicatorId: this._replicatorId,
|
|
3833
3872
|
changeListenerToken: token,
|