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 +7 -5
- package/package.json +1 -1
- package/src/index.js +18 -12
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
|
|
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 >
|
|
670
|
-
|
|
671
|
+
if (durationInMilliseconds > 2000) {
|
|
672
|
+
_this18.optimize(query, exec_scope);
|
|
671
673
|
}
|
|
672
674
|
|
|
673
675
|
return response;
|
package/package.json
CHANGED
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 ?
|
|
272
|
-
|
|
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 ?
|
|
306
|
-
|
|
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 ?
|
|
315
|
-
|
|
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 ?
|
|
322
|
-
|
|
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
|
|
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 >
|
|
580
|
-
|
|
585
|
+
if (durationInMilliseconds > 2000) {
|
|
586
|
+
this.optimize(query, exec_scope);
|
|
581
587
|
}
|
|
582
588
|
return response;
|
|
583
589
|
}
|