spice-couchbase 2.0.35 → 2.0.37
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 +6 -19
- package/package.json +1 -1
- package/src/index.js +5 -17
package/build/index.js
CHANGED
|
@@ -204,13 +204,6 @@ module.exports = class Database {
|
|
|
204
204
|
function loadAllCollections() {
|
|
205
205
|
return _loadAllCollections.apply(this, arguments);
|
|
206
206
|
}
|
|
207
|
-
/* console.log("================================");
|
|
208
|
-
console.log(
|
|
209
|
-
"Collection Set",
|
|
210
|
-
spice?.db?.collections?.has(collection_name),
|
|
211
|
-
collection_name
|
|
212
|
-
); */
|
|
213
|
-
|
|
214
207
|
|
|
215
208
|
function _loadAllCollections() {
|
|
216
209
|
_loadAllCollections = _asyncToGenerator(function* () {
|
|
@@ -237,14 +230,11 @@ module.exports = class Database {
|
|
|
237
230
|
}
|
|
238
231
|
|
|
239
232
|
if ((_spice2 = spice) === null || _spice2 === void 0 ? void 0 : (_spice2$db = _spice2.db) === null || _spice2$db === void 0 ? void 0 : (_spice2$db$collection = _spice2$db.collections) === null || _spice2$db$collection === void 0 ? void 0 : _spice2$db$collection.has(collection_name)) {
|
|
240
|
-
//console.log("Using Internal Collection Set", true);
|
|
241
233
|
return true;
|
|
242
234
|
} else {
|
|
243
235
|
var _spice3, _spice3$db, _spice3$db$collection;
|
|
244
236
|
|
|
245
|
-
|
|
246
|
-
spice.db.collections = yield loadAllCollections(); //console.log("Collection Set", spice.db.collections.entries());
|
|
247
|
-
|
|
237
|
+
spice.db.collections = yield loadAllCollections();
|
|
248
238
|
return (_spice3 = spice) === null || _spice3 === void 0 ? void 0 : (_spice3$db = _spice3.db) === null || _spice3$db === void 0 ? void 0 : (_spice3$db$collection = _spice3$db.collections) === null || _spice3$db$collection === void 0 ? void 0 : _spice3$db$collection.has(collection_name);
|
|
249
239
|
}
|
|
250
240
|
} catch (e) {
|
|
@@ -333,7 +323,6 @@ module.exports = class Database {
|
|
|
333
323
|
console.log(e.message, e, doc_id);
|
|
334
324
|
}
|
|
335
325
|
|
|
336
|
-
console.log("Return from Insert", doc_id);
|
|
337
326
|
return yield _this9.get(doc_id);
|
|
338
327
|
})();
|
|
339
328
|
}
|
|
@@ -381,13 +370,9 @@ module.exports = class Database {
|
|
|
381
370
|
var _this14 = this;
|
|
382
371
|
|
|
383
372
|
return _asyncToGenerator(function* () {
|
|
384
|
-
/* var that = this; */
|
|
385
|
-
|
|
386
|
-
/* return new Promise(async function (resolve, reject) { */
|
|
387
373
|
if (keys.length == 0) {
|
|
388
374
|
return [];
|
|
389
|
-
}
|
|
390
|
-
|
|
375
|
+
}
|
|
391
376
|
|
|
392
377
|
if (_.isArray(keys) && keys.length > 0) {
|
|
393
378
|
var functions = _.map(keys, key => (_this14.use_bucket_name ? _this14.connection : _this14.collection).get(key));
|
|
@@ -491,6 +476,7 @@ module.exports = class Database {
|
|
|
491
476
|
var order_by = arguments.length > 5 ? arguments[5] : undefined;
|
|
492
477
|
var do_count = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : "false";
|
|
493
478
|
var query_scope = arguments.length > 7 ? arguments[7] : undefined;
|
|
479
|
+
var join = arguments.length > 8 ? arguments[8] : undefined;
|
|
494
480
|
return _asyncToGenerator(function* () {
|
|
495
481
|
var is_legacy = _this15.scope_name !== "_default" && _this15.collection_name !== "_default";
|
|
496
482
|
var bucket = "`".concat(_this15.use_bucket_name ? _this15.bucket : _this15.collection_name, "`");
|
|
@@ -508,7 +494,7 @@ module.exports = class Database {
|
|
|
508
494
|
columns = "".concat(columns).concat(fix);
|
|
509
495
|
}
|
|
510
496
|
|
|
511
|
-
var front_query = "SELECT ".concat(columns, " FROM ").concat(bucket);
|
|
497
|
+
var front_query = "SELECT ".concat(columns, " FROM ").concat(bucket, " ").concat(join);
|
|
512
498
|
var conditions = [];
|
|
513
499
|
|
|
514
500
|
if (_this15.use_bucket_name) {
|
|
@@ -521,7 +507,8 @@ module.exports = class Database {
|
|
|
521
507
|
|
|
522
508
|
var where_clause = conditions.length ? " WHERE " : "";
|
|
523
509
|
query = front_query + where_clause + conditions.join(" AND ");
|
|
524
|
-
var count_query = "SELECT count(meta().id) as count FROM ".concat(bucket).concat(where_clause);
|
|
510
|
+
var count_query = "SELECT count(meta(".concat(bucket, ").id) as count FROM ").concat(bucket, " ").concat(join, " ").concat(where_clause); //console.log("Cound Query::", count_query);
|
|
511
|
+
|
|
525
512
|
var order_by_clause = order_by ? " ORDER BY ".concat(order_by) : "";
|
|
526
513
|
var limit_clause = limit > 0 ? " LIMIT ".concat(limit) : "";
|
|
527
514
|
var offset_clause = offset > 0 ? " OFFSET ".concat(offset) : "";
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -211,20 +211,10 @@ module.exports = class Database {
|
|
|
211
211
|
});
|
|
212
212
|
return collectionSet;
|
|
213
213
|
}
|
|
214
|
-
/* console.log("================================");
|
|
215
|
-
console.log(
|
|
216
|
-
"Collection Set",
|
|
217
|
-
spice?.db?.collections?.has(collection_name),
|
|
218
|
-
collection_name
|
|
219
|
-
); */
|
|
220
214
|
if (spice?.db?.collections?.has(collection_name)) {
|
|
221
|
-
//console.log("Using Internal Collection Set", true);
|
|
222
215
|
return true;
|
|
223
216
|
} else {
|
|
224
|
-
//console.log("Using Internal Collection Set", false);
|
|
225
|
-
|
|
226
217
|
spice.db.collections = await loadAllCollections();
|
|
227
|
-
//console.log("Collection Set", spice.db.collections.entries());
|
|
228
218
|
return spice?.db?.collections?.has(collection_name);
|
|
229
219
|
}
|
|
230
220
|
} catch (e) {
|
|
@@ -300,7 +290,6 @@ module.exports = class Database {
|
|
|
300
290
|
} catch (e) {
|
|
301
291
|
console.log(e.message, e, doc_id);
|
|
302
292
|
}
|
|
303
|
-
console.log("Return from Insert", doc_id);
|
|
304
293
|
return await this.get(doc_id);
|
|
305
294
|
}
|
|
306
295
|
|
|
@@ -339,12 +328,9 @@ module.exports = class Database {
|
|
|
339
328
|
}
|
|
340
329
|
|
|
341
330
|
async multi_get(keys, keep_type) {
|
|
342
|
-
/* var that = this; */
|
|
343
|
-
/* return new Promise(async function (resolve, reject) { */
|
|
344
331
|
if (keys.length == 0) {
|
|
345
332
|
return [];
|
|
346
333
|
}
|
|
347
|
-
// console.log("on Multiget", keys);
|
|
348
334
|
if (_.isArray(keys) && keys.length > 0) {
|
|
349
335
|
let functions = _.map(keys, (key) =>
|
|
350
336
|
(this.use_bucket_name ? this.connection : this.collection).get(key)
|
|
@@ -431,7 +417,8 @@ module.exports = class Database {
|
|
|
431
417
|
offset = 0,
|
|
432
418
|
order_by,
|
|
433
419
|
do_count = "false",
|
|
434
|
-
query_scope
|
|
420
|
+
query_scope,
|
|
421
|
+
join
|
|
435
422
|
) {
|
|
436
423
|
const is_legacy =
|
|
437
424
|
this.scope_name !== "_default" && this.collection_name !== "_default";
|
|
@@ -453,7 +440,7 @@ module.exports = class Database {
|
|
|
453
440
|
} else if (!containsIdWithSpace(columns)) {
|
|
454
441
|
columns = `${columns}${fix}`;
|
|
455
442
|
}
|
|
456
|
-
const front_query = `SELECT ${columns} FROM ${bucket}`;
|
|
443
|
+
const front_query = `SELECT ${columns} FROM ${bucket} ${join}`;
|
|
457
444
|
const conditions = [];
|
|
458
445
|
|
|
459
446
|
if (this.use_bucket_name) {
|
|
@@ -466,7 +453,8 @@ module.exports = class Database {
|
|
|
466
453
|
const where_clause = conditions.length ? " WHERE " : "";
|
|
467
454
|
query = front_query + where_clause + conditions.join(" AND ");
|
|
468
455
|
|
|
469
|
-
const count_query = `SELECT count(meta().id) as count FROM ${bucket}${where_clause}`;
|
|
456
|
+
const count_query = `SELECT count(meta(${bucket}).id) as count FROM ${bucket} ${join} ${where_clause}`;
|
|
457
|
+
//console.log("Cound Query::", count_query);
|
|
470
458
|
const order_by_clause = order_by ? ` ORDER BY ${order_by}` : "";
|
|
471
459
|
const limit_clause = limit > 0 ? ` LIMIT ${limit}` : "";
|
|
472
460
|
const offset_clause = offset > 0 ? ` OFFSET ${offset}` : "";
|