spice-couchbase 2.0.27 → 2.0.29

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
@@ -456,7 +456,7 @@ module.exports = class Database {
456
456
  var fix = ", META(".concat(bucket, ").id AS id");
457
457
 
458
458
  if (columns === "*" || !columns) {
459
- columns = "(".concat(bucket, ").*");
459
+ columns = "(".concat(bucket, ").* ").concat(fix);
460
460
  } else if (!containsIdWithSpace(columns)) {
461
461
  columns = "".concat(columns).concat(fix);
462
462
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-couchbase",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -426,7 +426,7 @@ module.exports = class Database {
426
426
  const fix = `, META(${bucket}).id AS id`;
427
427
 
428
428
  if (columns === "*" || !columns) {
429
- columns = `(${bucket}).*`;
429
+ columns = `(${bucket}).* ${fix}`;
430
430
  } else if (!containsIdWithSpace(columns)) {
431
431
  columns = `${columns}${fix}`;
432
432
  }
@@ -531,12 +531,25 @@ module.exports = class Database {
531
531
  return response.rows;
532
532
  }
533
533
 
534
- async query(query, query_scope = "cluster") {
534
+ /* async query(query, query_scope = "cluster") {
535
535
  let scope = query_scope || this.query_scope;
536
536
  if (scope == "cluster") {
537
537
  return await this.cluster.query(query);
538
538
  } else {
539
539
  return await this.scope.query(query);
540
540
  }
541
+ } */
542
+
543
+ async query(query, query_scope = "cluster") {
544
+ let scope = query_scope || this.query_scope;
545
+
546
+ // Escape the query string
547
+ const sanitizedQuery = couchbase.N1qlQuery.fromString(query).toString();
548
+
549
+ if (scope === "cluster") {
550
+ return await this.cluster.query(sanitizedQuery);
551
+ } else {
552
+ return await this.scope.query(sanitizedQuery);
553
+ }
541
554
  }
542
555
  };