cbl-ionic 0.2.4 → 0.2.6

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/plugin.js CHANGED
@@ -2306,18 +2306,24 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
2306
2306
  * @function
2307
2307
  */
2308
2308
  async getDocument(id) {
2309
- const docJson = await this._engine.database_GetDocument({
2310
- name: this._databaseName,
2309
+ const docJson = await this._engine.collection_GetDocument({
2311
2310
  docId: id,
2311
+ name: this._databaseName,
2312
+ scopeName: "_default",
2313
+ collectionName: "_default",
2312
2314
  });
2313
- if (docJson) {
2315
+ const collection = await this.defaultCollection();
2316
+ // @ts-expect-error - _id is used in getId()
2317
+ if (docJson && docJson._id) {
2314
2318
  // @ts-expect-error - _data is used in getData()
2315
2319
  const data = docJson._data;
2316
2320
  // @ts-expect-error - _sequence is used in getSequence()
2317
2321
  const sequence = docJson._sequence;
2318
2322
  // @ts-expect-error _id exists in documents
2319
2323
  const retId = docJson._id;
2320
- return Promise.resolve(new Document(retId, sequence, data));
2324
+ // @ts-expect-error - _revId is used in getRevisionID()
2325
+ const revisionID = docJson._revId;
2326
+ return Promise.resolve(new Document(retId, sequence, revisionID, collection, data));
2321
2327
  }
2322
2328
  else {
2323
2329
  return Promise.resolve(null);
@@ -2329,15 +2335,18 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
2329
2335
  * @function
2330
2336
  */
2331
2337
  async save(document, concurrencyControl = null) {
2332
- const ret = await this._engine.database_Save({
2333
- name: this._databaseName,
2338
+ const ret = await this._engine.collection_Save({
2334
2339
  id: document.getId(),
2335
2340
  document: document.toJsonString(),
2336
2341
  blobs: document.blobsToJsonString(),
2337
2342
  concurrencyControl: concurrencyControl,
2343
+ name: this._databaseName,
2344
+ scopeName: "_default",
2345
+ collectionName: "_default",
2338
2346
  });
2339
- const id = ret._id;
2340
- document.setId(id);
2347
+ document.setId(ret._id);
2348
+ document.setRevisionID(ret._revId);
2349
+ document.setSequence(ret._sequence);
2341
2350
  }
2342
2351
  /**
2343
2352
  * @deprecated createIndex is deprecated. Use Collection createIndex instead.
@@ -3096,7 +3105,12 @@ var capacitorIonicCouchbaseLite = (function (exports, core) {
3096
3105
  }
3097
3106
  else if (arguments.length === 1) {
3098
3107
  // Just ID
3099
- super(id, null, null, null, {});
3108
+ if (id === null || id.length === 0) {
3109
+ super(null, null, null, null, {});
3110
+ }
3111
+ else {
3112
+ super(id, null, null, null, {});
3113
+ }
3100
3114
  }
3101
3115
  else if (arguments.length === 2 && typeof sequenceNoOrData === 'object') {
3102
3116
  // ID and data