spice-couchbase 2.0.19 → 2.0.20

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
@@ -20,6 +20,10 @@ var {
20
20
 
21
21
  var qs = require("qs");
22
22
 
23
+ var {
24
+ ConflictResolutionType
25
+ } = require("couchbase");
26
+
23
27
  if (!Promise.allSettled) {
24
28
  Promise.allSettled = promises => Promise.all(promises.map((promise, i) => promise.then(value => ({
25
29
  status: "fulfilled",
@@ -50,19 +54,26 @@ module.exports = class Database {
50
54
  this.collection_manager = spice.database.buckets[connection].collections();
51
55
  this.auto_create_collection = auto_create_collection || (collection || spice.config.database.connections[connection].collection) != undefined && (collection || spice.config.database.connections[connection].collection) != "default" && (scope || spice.config.database.connections[connection].scope) != "_default";
52
56
  this.collection_name = collection || spice.config.database.connections[connection].collection || "_default";
57
+ /* console.log(
58
+ "Collection",
59
+ collection,
60
+ spice.config.database.connections[connection].collection,
61
+ this.collection_name
62
+ );*/
63
+
53
64
  this.scope_name = scope || spice.config.database.connections[connection].scope || "_default";
54
65
  this.scope = spice.database.scopes[connection];
55
66
  this.full_text_index = spice.config.database.connections[connection].full_text_index || full_text_index;
56
67
  this.N1qlQuery = couchbase.N1qlQuery;
57
68
  this.SearchQuery = couchbase.SearchQuery;
58
- this.connection = this.scope.collection(this.collection_name);
69
+ this.collection = this.scope.collection(this.collection_name);
59
70
  this.userManager = this.getUserManager(connection);
60
71
 
61
72
  if (this.auto_create_collection) {
62
73
  this.upsertCollection();
63
74
  }
64
75
 
65
- this.use_bucket_name = !spice.config.database.connections[this.connection_name].scope;
76
+ this.use_bucket_name = spice.config.database.connections[this.connection_name].scope == undefined;
66
77
  }
67
78
  }
68
79
 
@@ -244,6 +255,7 @@ module.exports = class Database {
244
255
  var _this9 = this;
245
256
 
246
257
  return _asyncToGenerator(function* () {
258
+ console.log("insert", _this9.use_bucket_name, _this9.connection._name, _this9.collection._name);
247
259
  yield (_this9.use_bucket_name ? _this9.connection : _this9.collection).insert(doc_id, document, {
248
260
  expiry: expiry
249
261
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-couchbase",
3
- "version": "2.0.19",
3
+ "version": "2.0.20",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -4,6 +4,7 @@ let _ = require("lodash");
4
4
  let couchbase = require("couchbase");
5
5
  const { default: axios } = require("axios");
6
6
  var qs = require("qs");
7
+ const { ConflictResolutionType } = require("couchbase");
7
8
 
8
9
  if (!Promise.allSettled) {
9
10
  Promise.allSettled = (promises) =>
@@ -51,10 +52,17 @@ module.exports = class Database {
51
52
  "default" &&
52
53
  (scope || spice.config.database.connections[connection].scope) !=
53
54
  "_default");
55
+
54
56
  this.collection_name =
55
57
  collection ||
56
58
  spice.config.database.connections[connection].collection ||
57
59
  "_default";
60
+ /* console.log(
61
+ "Collection",
62
+ collection,
63
+ spice.config.database.connections[connection].collection,
64
+ this.collection_name
65
+ );*/
58
66
  this.scope_name =
59
67
  scope ||
60
68
  spice.config.database.connections[connection].scope ||
@@ -65,14 +73,15 @@ module.exports = class Database {
65
73
  full_text_index;
66
74
  this.N1qlQuery = couchbase.N1qlQuery;
67
75
  this.SearchQuery = couchbase.SearchQuery;
68
- this.connection = this.scope.collection(this.collection_name);
76
+ this.collection = this.scope.collection(this.collection_name);
69
77
  this.userManager = this.getUserManager(connection);
70
78
  if (this.auto_create_collection) {
71
79
  this.upsertCollection();
72
80
  }
73
81
 
74
82
  this.use_bucket_name =
75
- !spice.config.database.connections[this.connection_name].scope;
83
+ spice.config.database.connections[this.connection_name].scope ==
84
+ undefined;
76
85
  }
77
86
  }
78
87
 
@@ -236,6 +245,12 @@ module.exports = class Database {
236
245
  }
237
246
 
238
247
  async insert(doc_id, document, expiry) {
248
+ console.log(
249
+ "insert",
250
+ this.use_bucket_name,
251
+ this.connection._name,
252
+ this.collection._name
253
+ );
239
254
  await (this.use_bucket_name ? this.connection : this.collection).insert(
240
255
  doc_id,
241
256
  document,