spice-couchbase 2.0.22 → 2.0.23

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
@@ -347,18 +347,20 @@ module.exports = class Database {
347
347
 
348
348
  var returned_all = yield Promise.allSettled(functions);
349
349
 
350
- var responses = _.flatten(_.compact(_.map(returned_all, returned_obj => {
351
- if (returned_obj.status == "fulfilled") return returned_obj.value;
352
- })));
350
+ var responses = _.flatten(_.map(returned_all, returned_obj => {
351
+ return returned_obj === null || returned_obj === void 0 ? void 0 : returned_obj.value;
352
+ }));
353
+
354
+ return _.compact(_.map(responses, (res, index) => {
355
+ if (res) {
356
+ if (!keep_type) {
357
+ delete res.value.type;
358
+ }
353
359
 
354
- return _.map(responses, (res, index) => {
355
- if (!keep_type) {
356
- delete res.value.type;
360
+ res.value.id = keys[index];
361
+ return res.value;
357
362
  }
358
-
359
- res.value.id = keys[index];
360
- return res.value;
361
- });
363
+ }));
362
364
  } else {
363
365
  return [];
364
366
  }
@@ -432,52 +434,30 @@ module.exports = class Database {
432
434
  }());
433
435
  }
434
436
 
435
- search(type, columns, query, limit, offset, order_by, do_count, query_scope) {
437
+ search(type, columns, query) {
436
438
  var _this15 = this;
437
439
 
440
+ var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
441
+ var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
442
+ var order_by = arguments.length > 5 ? arguments[5] : undefined;
443
+ var do_count = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : "false";
444
+ var query_scope = arguments.length > 7 ? arguments[7] : undefined;
438
445
  return _asyncToGenerator(function* () {
439
446
  var is_legacy = _this15.scope_name !== "_default" && _this15.collection_name !== "_default";
440
- var alias = "_reference";
441
447
  var bucket = "`".concat(_this15.use_bucket_name ? _this15.bucket : _this15.collection_name, "`");
442
448
 
443
449
  try {
444
- //let uses_scopes = this.scope this.scope_name !== "_default";
445
- if (do_count == undefined) {
446
- do_count = "false";
447
- }
448
-
449
- var fix = "";
450
- var count_query = "";
451
-
452
- if (!limit) {
453
- limit = 0;
454
- }
455
-
456
- if (!offset) {
457
- offset = 0;
458
- }
459
-
460
- if (columns == "*") {
461
- columns = "(" + bucket + ").*";
462
- fix = ", META(" + bucket + ").id AS id";
463
- }
464
-
465
- if (!columns) {
466
- columns = "(" + bucket + ").*";
467
- fix = ", META(" + bucket + ").id AS id";
468
- }
450
+ var fix = ", META(".concat(bucket, ").id AS id");
469
451
 
470
- if (columns == "id") {
471
- fix = ", META(" + bucket + ").id AS id";
452
+ if (columns === "*" || !columns) {
453
+ columns = "(".concat(bucket, ").*");
454
+ } else if (columns !== "id") {
455
+ columns = "".concat(columns).concat(fix);
456
+ } else {
472
457
  columns = "";
473
458
  }
474
459
 
475
460
  var front_query = "SELECT ".concat(columns, " ").concat(fix, " FROM ").concat(bucket);
476
-
477
- if (is_legacy || query) {
478
- front_query += " WHERE ";
479
- }
480
-
481
461
  var conditions = [];
482
462
 
483
463
  if (_this15.use_bucket_name) {
@@ -488,27 +468,13 @@ module.exports = class Database {
488
468
  conditions.push(query);
489
469
  }
490
470
 
491
- query = front_query + conditions.join(" AND ");
492
- count_query = "SELECT count(meta().id) as count FROM ".concat(bucket);
493
-
494
- if (_this15.use_bucket_name || query) {
495
- count_query += " WHERE ";
496
- }
497
-
498
- query = front_query + conditions.join(" AND ");
499
-
500
- if (order_by) {
501
- query = "".concat(query, " ORDER BY ").concat(order_by);
502
- }
503
-
504
- if (limit > 0) {
505
- query = query + " LIMIT " + limit;
506
- }
507
-
508
- if (offset > 0) {
509
- query = query + " OFFSET " + offset;
510
- }
511
-
471
+ var where_clause = conditions.length ? " WHERE " : "";
472
+ query = front_query + where_clause + conditions.join(" AND ");
473
+ var count_query = "SELECT count(meta().id) as count FROM ".concat(bucket).concat(where_clause);
474
+ var order_by_clause = order_by ? " ORDER BY ".concat(order_by) : "";
475
+ var limit_clause = limit > 0 ? " LIMIT ".concat(limit) : "";
476
+ var offset_clause = offset > 0 ? " OFFSET ".concat(offset) : "";
477
+ query = query + order_by_clause + limit_clause + offset_clause;
512
478
  var active_query_space = query_scope || !_this15.use_bucket_name ? "scope" : "cluster";
513
479
  var queries = [_this15.getData(query, active_query_space)];
514
480
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-couchbase",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -329,20 +329,22 @@ module.exports = class Database {
329
329
  let returned_all = await Promise.allSettled(functions);
330
330
 
331
331
  let responses = _.flatten(
332
- _.compact(
333
- _.map(returned_all, (returned_obj) => {
334
- if (returned_obj.status == "fulfilled") return returned_obj.value;
335
- })
336
- )
332
+ _.map(returned_all, (returned_obj) => {
333
+ return returned_obj?.value;
334
+ })
337
335
  );
338
336
 
339
- return _.map(responses, (res, index) => {
340
- if (!keep_type) {
341
- delete res.value.type;
342
- }
343
- res.value.id = keys[index];
344
- return res.value;
345
- });
337
+ return _.compact(
338
+ _.map(responses, (res, index) => {
339
+ if (res) {
340
+ if (!keep_type) {
341
+ delete res.value.type;
342
+ }
343
+ res.value.id = keys[index];
344
+ return res.value;
345
+ }
346
+ })
347
+ );
346
348
  } else {
347
349
  return [];
348
350
  }