spice-couchbase 2.0.39 → 2.0.41
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 +11 -9
- package/package.json +1 -1
- package/src/index.js +21 -23
package/build/index.js
CHANGED
|
@@ -88,24 +88,24 @@ module.exports = class Database {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
setGlobalConnectionObject(
|
|
91
|
+
setGlobalConnectionObject(collection) {
|
|
92
92
|
if (spice.checked_collections == undefined) {
|
|
93
93
|
spice.checked_collections = {};
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
_.set(spice.checked_collections,
|
|
96
|
+
_.set(spice.checked_collections, collection, true);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
checkGlobelConnectionObject(
|
|
99
|
+
checkGlobelConnectionObject(collection) {
|
|
100
100
|
if (spice.checked_collections == undefined) {
|
|
101
101
|
spice.checked_collections = {};
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
if (_.get(spice.checked_collections,
|
|
104
|
+
if (_.get(spice.checked_collections, collection)) {
|
|
105
105
|
return true;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
this.setGlobalConnectionObject(
|
|
108
|
+
this.setGlobalConnectionObject(collection);
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -177,9 +177,9 @@ module.exports = class Database {
|
|
|
177
177
|
|
|
178
178
|
return _asyncToGenerator(function* () {
|
|
179
179
|
try {
|
|
180
|
-
var collection_exists = yield _this3.collectionExists(_this3.collection_name, _this3.scope_name);
|
|
181
|
-
|
|
182
180
|
if (!_this3.checkGlobelConnectionObject(_this3.collection_name)) {
|
|
181
|
+
var collection_exists = yield _this3.collectionExists(_this3.collection_name, _this3.scope_name);
|
|
182
|
+
|
|
183
183
|
if (!collection_exists) {
|
|
184
184
|
yield _this3.createCollection(_this3.collection_name, _this3.scope_name);
|
|
185
185
|
yield _this3.wait(2000);
|
|
@@ -348,11 +348,13 @@ module.exports = class Database {
|
|
|
348
348
|
})();
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
update(doc_id, document) {
|
|
351
|
+
update(doc_id, document, expiry) {
|
|
352
352
|
var _this12 = this;
|
|
353
353
|
|
|
354
354
|
return _asyncToGenerator(function* () {
|
|
355
|
-
var res = yield (_this12.use_bucket_name ? _this12.connection : _this12.collection).replace(doc_id, document
|
|
355
|
+
var res = yield (_this12.use_bucket_name ? _this12.connection : _this12.collection).replace(doc_id, document, {
|
|
356
|
+
expiry: expiry
|
|
357
|
+
});
|
|
356
358
|
return res.value;
|
|
357
359
|
})();
|
|
358
360
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -91,21 +91,21 @@ module.exports = class Database {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
setGlobalConnectionObject(
|
|
94
|
+
setGlobalConnectionObject(collection) {
|
|
95
95
|
if (spice.checked_collections == undefined) {
|
|
96
96
|
spice.checked_collections = {};
|
|
97
97
|
}
|
|
98
|
-
_.set(spice.checked_collections,
|
|
98
|
+
_.set(spice.checked_collections, collection, true);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
checkGlobelConnectionObject(
|
|
101
|
+
checkGlobelConnectionObject(collection) {
|
|
102
102
|
if (spice.checked_collections == undefined) {
|
|
103
103
|
spice.checked_collections = {};
|
|
104
104
|
}
|
|
105
|
-
if (_.get(spice.checked_collections,
|
|
105
|
+
if (_.get(spice.checked_collections, collection)) {
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
|
-
this.setGlobalConnectionObject(
|
|
108
|
+
this.setGlobalConnectionObject(collection);
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -173,11 +173,11 @@ module.exports = class Database {
|
|
|
173
173
|
|
|
174
174
|
async upsertCollection() {
|
|
175
175
|
try {
|
|
176
|
-
let collection_exists = await this.collectionExists(
|
|
177
|
-
this.collection_name,
|
|
178
|
-
this.scope_name
|
|
179
|
-
);
|
|
180
176
|
if (!this.checkGlobelConnectionObject(this.collection_name)) {
|
|
177
|
+
let collection_exists = await this.collectionExists(
|
|
178
|
+
this.collection_name,
|
|
179
|
+
this.scope_name
|
|
180
|
+
);
|
|
181
181
|
if (!collection_exists) {
|
|
182
182
|
await this.createCollection(this.collection_name, this.scope_name);
|
|
183
183
|
await this.wait(2000);
|
|
@@ -267,9 +267,8 @@ module.exports = class Database {
|
|
|
267
267
|
|
|
268
268
|
async get(doc_id) {
|
|
269
269
|
try {
|
|
270
|
-
let response = await (
|
|
271
|
-
? this.connection
|
|
272
|
-
: this.collection
|
|
270
|
+
let response = await (
|
|
271
|
+
this.use_bucket_name ? this.connection : this.collection
|
|
273
272
|
).get(doc_id);
|
|
274
273
|
|
|
275
274
|
return { id: doc_id, ...response.content };
|
|
@@ -302,27 +301,26 @@ module.exports = class Database {
|
|
|
302
301
|
}
|
|
303
302
|
|
|
304
303
|
async count(doc_id, adjustment, initial_value) {
|
|
305
|
-
let res = await (
|
|
306
|
-
? this.connection
|
|
307
|
-
: this.collection
|
|
304
|
+
let res = await (
|
|
305
|
+
this.use_bucket_name ? this.connection : this.collection
|
|
308
306
|
).counter(doc_id, adjustment, {
|
|
309
307
|
initial: initial_value,
|
|
310
308
|
});
|
|
311
309
|
return res.value;
|
|
312
310
|
}
|
|
313
311
|
|
|
314
|
-
async update(doc_id, document) {
|
|
315
|
-
let res = await (
|
|
316
|
-
? this.connection
|
|
317
|
-
|
|
318
|
-
|
|
312
|
+
async update(doc_id, document, expiry) {
|
|
313
|
+
let res = await (
|
|
314
|
+
this.use_bucket_name ? this.connection : this.collection
|
|
315
|
+
).replace(doc_id, document, {
|
|
316
|
+
expiry: expiry,
|
|
317
|
+
});
|
|
319
318
|
return res.value;
|
|
320
319
|
}
|
|
321
320
|
|
|
322
321
|
async delete(doc_id) {
|
|
323
|
-
let res = await (
|
|
324
|
-
? this.connection
|
|
325
|
-
: this.collection
|
|
322
|
+
let res = await (
|
|
323
|
+
this.use_bucket_name ? this.connection : this.collection
|
|
326
324
|
).remove(doc_id);
|
|
327
325
|
return res.value;
|
|
328
326
|
}
|