spice-couchbase 2.0.26 → 2.0.28

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
@@ -434,9 +434,11 @@ module.exports = class Database {
434
434
  }());
435
435
  }
436
436
 
437
- search(type, columns, query) {
437
+ search(type) {
438
438
  var _this15 = this;
439
439
 
440
+ var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
441
+ var query = arguments.length > 2 ? arguments[2] : undefined;
440
442
  var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
441
443
  var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
442
444
  var order_by = arguments.length > 5 ? arguments[5] : undefined;
@@ -447,21 +449,19 @@ module.exports = class Database {
447
449
  var bucket = "`".concat(_this15.use_bucket_name ? _this15.bucket : _this15.collection_name, "`");
448
450
 
449
451
  function containsIdWithSpace(str) {
450
- return /\b\.?id\b/i.test(str); // Updated regex to match "id" as a separate word or preceded by a dot (".id")
452
+ return /(?<=\W|^)(?!`)(?:(?:\w+`?\.)*)(?:\w+`?\.)?id(?<!`)(?!\w)/i.test(str);
451
453
  }
452
454
 
453
455
  try {
454
456
  var fix = ", META(".concat(bucket, ").id AS id");
455
457
 
456
458
  if (columns === "*" || !columns) {
457
- columns = "(".concat(bucket, ").*");
458
- } else if (columns !== "id") {
459
+ columns = "(".concat(bucket, ").* ").concat(fix);
460
+ } else if (!containsIdWithSpace(columns)) {
459
461
  columns = "".concat(columns).concat(fix);
460
- } else {
461
- columns = "";
462
462
  }
463
463
 
464
- var front_query = "SELECT ".concat(columns, " ").concat(containsIdWithSpace(columns) ? "" : fix, " FROM ").concat(bucket);
464
+ var front_query = "SELECT ".concat(columns, " FROM ").concat(bucket);
465
465
  var conditions = [];
466
466
 
467
467
  if (_this15.use_bucket_name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-couchbase",
3
- "version": "2.0.26",
3
+ "version": "2.0.28",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -402,7 +402,7 @@ module.exports = class Database {
402
402
 
403
403
  async search(
404
404
  type,
405
- columns,
405
+ columns = "",
406
406
  query,
407
407
  limit = 0,
408
408
  offset = 0,
@@ -417,23 +417,20 @@ module.exports = class Database {
417
417
  }\``;
418
418
 
419
419
  function containsIdWithSpace(str) {
420
- return /\b\.?id\b/i.test(str); // Updated regex to match "id" as a separate word or preceded by a dot (".id")
420
+ return /(?<=\W|^)(?!`)(?:(?:\w+`?\.)*)(?:\w+`?\.)?id(?<!`)(?!\w)/i.test(
421
+ str
422
+ );
421
423
  }
422
424
 
423
425
  try {
424
426
  const fix = `, META(${bucket}).id AS id`;
425
427
 
426
428
  if (columns === "*" || !columns) {
427
- columns = `(${bucket}).*`;
428
- } else if (columns !== "id") {
429
+ columns = `(${bucket}).* ${fix}`;
430
+ } else if (!containsIdWithSpace(columns)) {
429
431
  columns = `${columns}${fix}`;
430
- } else {
431
- columns = "";
432
432
  }
433
-
434
- const front_query = `SELECT ${columns} ${
435
- containsIdWithSpace(columns) ? "" : fix
436
- } FROM ${bucket}`;
433
+ const front_query = `SELECT ${columns} FROM ${bucket}`;
437
434
  const conditions = [];
438
435
 
439
436
  if (this.use_bucket_name) {