spice-couchbase 2.0.41 → 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 +3 -3
- package/package.json +1 -1
- package/src/index.js +15 -11
package/build/index.js
CHANGED
|
@@ -518,7 +518,7 @@ module.exports = class Database {
|
|
|
518
518
|
var active_query_space = query_scope || !_this15.use_bucket_name ? "scope" : "cluster";
|
|
519
519
|
var queries = [_this15.getData(query, active_query_space)];
|
|
520
520
|
|
|
521
|
-
if (do_count
|
|
521
|
+
if (do_count != "false") {
|
|
522
522
|
queries.push(_this15.getCount(count_query, active_query_space));
|
|
523
523
|
}
|
|
524
524
|
|
|
@@ -668,8 +668,8 @@ module.exports = class Database {
|
|
|
668
668
|
|
|
669
669
|
var durationInMilliseconds = (endTime - startTime) / BigInt(1000000); // optimize if response time is greater than 1 second
|
|
670
670
|
|
|
671
|
-
if (durationInMilliseconds >
|
|
672
|
-
|
|
671
|
+
if (durationInMilliseconds > 2000) {
|
|
672
|
+
_this18.optimize(query, exec_scope);
|
|
673
673
|
}
|
|
674
674
|
|
|
675
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,8 +303,9 @@ 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;
|
|
@@ -311,8 +313,9 @@ module.exports = class Database {
|
|
|
311
313
|
|
|
312
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, {
|
|
316
319
|
expiry: expiry,
|
|
317
320
|
});
|
|
318
321
|
return res.value;
|
|
@@ -320,8 +323,9 @@ module.exports = class Database {
|
|
|
320
323
|
|
|
321
324
|
async delete(doc_id) {
|
|
322
325
|
let res = await (
|
|
323
|
-
this.use_bucket_name ?
|
|
324
|
-
|
|
326
|
+
this.use_bucket_name ?
|
|
327
|
+
this.connection
|
|
328
|
+
: this.collection).remove(doc_id);
|
|
325
329
|
return res.value;
|
|
326
330
|
}
|
|
327
331
|
|
|
@@ -462,7 +466,7 @@ module.exports = class Database {
|
|
|
462
466
|
const active_query_space =
|
|
463
467
|
query_scope || !this.use_bucket_name ? "scope" : "cluster";
|
|
464
468
|
const queries = [this.getData(query, active_query_space)];
|
|
465
|
-
if (do_count
|
|
469
|
+
if (do_count != "false") {
|
|
466
470
|
queries.push(this.getCount(count_query, active_query_space));
|
|
467
471
|
}
|
|
468
472
|
const responses = await Promise.all(queries);
|
|
@@ -578,8 +582,8 @@ module.exports = class Database {
|
|
|
578
582
|
// Calculate duration in microseconds
|
|
579
583
|
let durationInMilliseconds = (endTime - startTime) / BigInt(1000000);
|
|
580
584
|
// optimize if response time is greater than 1 second
|
|
581
|
-
if (durationInMilliseconds >
|
|
582
|
-
|
|
585
|
+
if (durationInMilliseconds > 2000) {
|
|
586
|
+
this.optimize(query, exec_scope);
|
|
583
587
|
}
|
|
584
588
|
return response;
|
|
585
589
|
}
|