spice-couchbase 2.0.40 → 2.0.42

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/build/index.js CHANGED
@@ -348,11 +348,13 @@ module.exports = class Database {
348
348
  })();
349
349
  }
350
350
 
351
- update(doc_id, document) {
351
+ update(doc_id, document, expiry) {
352
352
  var _this12 = this;
353
353
 
354
354
  return _asyncToGenerator(function* () {
355
- var res = yield (_this12.use_bucket_name ? _this12.connection : _this12.collection).replace(doc_id, document);
355
+ var res = yield (_this12.use_bucket_name ? _this12.connection : _this12.collection).replace(doc_id, document, {
356
+ expiry: expiry
357
+ });
356
358
  return res.value;
357
359
  })();
358
360
  }
@@ -516,7 +518,7 @@ module.exports = class Database {
516
518
  var active_query_space = query_scope || !_this15.use_bucket_name ? "scope" : "cluster";
517
519
  var queries = [_this15.getData(query, active_query_space)];
518
520
 
519
- if (do_count === "true") {
521
+ if (do_count != "false") {
520
522
  queries.push(_this15.getCount(count_query, active_query_space));
521
523
  }
522
524
 
@@ -666,8 +668,8 @@ module.exports = class Database {
666
668
 
667
669
  var durationInMilliseconds = (endTime - startTime) / BigInt(1000000); // optimize if response time is greater than 1 second
668
670
 
669
- if (durationInMilliseconds > 1000) {
670
- yield _this18.optimize(query, exec_scope);
671
+ if (durationInMilliseconds > 2000) {
672
+ _this18.optimize(query, exec_scope);
671
673
  }
672
674
 
673
675
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-couchbase",
3
- "version": "2.0.40",
3
+ "version": "2.0.42",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -268,8 +268,9 @@ module.exports = class Database {
268
268
  async get(doc_id) {
269
269
  try {
270
270
  let response = await (
271
- this.use_bucket_name ? this.connection : this.collection
272
- ).get(doc_id);
271
+ this.use_bucket_name ?
272
+ this.connection
273
+ : this.collection).get(doc_id);
273
274
 
274
275
  return { id: doc_id, ...response.content };
275
276
  } catch (e) {
@@ -302,24 +303,29 @@ module.exports = class Database {
302
303
 
303
304
  async count(doc_id, adjustment, initial_value) {
304
305
  let res = await (
305
- this.use_bucket_name ? this.connection : this.collection
306
- ).counter(doc_id, adjustment, {
306
+ this.use_bucket_name ?
307
+ this.connection
308
+ : this.collection).counter(doc_id, adjustment, {
307
309
  initial: initial_value,
308
310
  });
309
311
  return res.value;
310
312
  }
311
313
 
312
- async update(doc_id, document) {
314
+ async update(doc_id, document, expiry) {
313
315
  let res = await (
314
- this.use_bucket_name ? this.connection : this.collection
315
- ).replace(doc_id, document);
316
+ this.use_bucket_name ?
317
+ this.connection
318
+ : this.collection).replace(doc_id, document, {
319
+ expiry: expiry,
320
+ });
316
321
  return res.value;
317
322
  }
318
323
 
319
324
  async delete(doc_id) {
320
325
  let res = await (
321
- this.use_bucket_name ? this.connection : this.collection
322
- ).remove(doc_id);
326
+ this.use_bucket_name ?
327
+ this.connection
328
+ : this.collection).remove(doc_id);
323
329
  return res.value;
324
330
  }
325
331
 
@@ -460,7 +466,7 @@ module.exports = class Database {
460
466
  const active_query_space =
461
467
  query_scope || !this.use_bucket_name ? "scope" : "cluster";
462
468
  const queries = [this.getData(query, active_query_space)];
463
- if (do_count === "true") {
469
+ if (do_count != "false") {
464
470
  queries.push(this.getCount(count_query, active_query_space));
465
471
  }
466
472
  const responses = await Promise.all(queries);
@@ -576,8 +582,8 @@ module.exports = class Database {
576
582
  // Calculate duration in microseconds
577
583
  let durationInMilliseconds = (endTime - startTime) / BigInt(1000000);
578
584
  // optimize if response time is greater than 1 second
579
- if (durationInMilliseconds > 1000) {
580
- await this.optimize(query, exec_scope);
585
+ if (durationInMilliseconds > 2000) {
586
+ this.optimize(query, exec_scope);
581
587
  }
582
588
  return response;
583
589
  }