@samet-it/be-couchbase-common 1.1.3 → 1.1.5
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/dist/connection/cb-direct.connection.d.ts +3 -2
- package/dist/connection/cb.connection.d.ts +4 -5
- package/dist/connection/cb.connection.js +6 -6
- package/dist/connection/index.types.d.ts +10 -7
- package/dist/repo/cb-direct.repo.d.ts +4 -4
- package/dist/repo/cb.repo.d.ts +6 -8
- package/dist/repo/cb.repo.js +15 -19
- package/dist/repo/index.types.d.ts +7 -13
- package/package.json +2 -2
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { CbConnection } from "./cb.connection";
|
|
2
|
+
import { UrnDef } from "@samet-it/be-base-common";
|
|
2
3
|
import type { DefDims, Entity, UrnDocLike, Pair, Portion, View } from "@samet-it/be-base-common";
|
|
3
4
|
import { type CbRepoDirectOpt, type CbRepoLike } from "../repo";
|
|
4
5
|
import type { CbDirectConnectionLike, CbDirectConnOpt } from "./index.types";
|
|
5
|
-
import type { KeyValue } from "@leyyo/common";
|
|
6
|
+
import type { KeyValue, StrKey } from "@leyyo/common";
|
|
6
7
|
/**
|
|
7
8
|
* Couchbase connection direct class
|
|
8
9
|
* */
|
|
9
10
|
export declare class CbDirectConnection extends CbConnection implements CbDirectConnectionLike {
|
|
10
11
|
constructor(opt?: CbDirectConnOpt);
|
|
11
12
|
/** @inheritDoc */
|
|
12
|
-
newRepo<
|
|
13
|
+
newRepo<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, KEYS extends string = StrKey<ENTITY>, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = ENTITY, PORTION extends Portion<ID> = Portion<ID>, R = unknown>(opt: CbRepoDirectOpt<ENTITY, ID, URN, DIMS, R>): CbRepoLike<ENTITY, ID, URN, KEYS, DIMS, PAIR, VIEW, PORTION>;
|
|
13
14
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { QueryResult, QueryMetaData } from 'couchbase';
|
|
2
2
|
import { type IgnoreFieldsByType, type ReplaceType } from "@leyyo/common";
|
|
3
3
|
import { DbConnection, type DbLines } from "@samet-it/be-db-common";
|
|
4
|
-
import type { CbConnectionLike, CbConnOpt, CbExecOpt, CbConnProps } from "./index.types";
|
|
5
|
-
import type { CbRepoDef } from "../repo";
|
|
4
|
+
import type { CbConnectionLike, CbConnOpt, CbExecOpt, CbConnProps, CbRepoLink } from "./index.types";
|
|
6
5
|
import type { DbQueryResultMore, DbQueryResultOne } from "@samet-it/be-db-common";
|
|
7
6
|
/**
|
|
8
7
|
* Couchbase connection abstract class
|
|
9
8
|
* */
|
|
10
|
-
export declare abstract class CbConnection extends DbConnection<
|
|
9
|
+
export declare abstract class CbConnection extends DbConnection<CbRepoLink, QueryMetaData, CbExecOpt> implements CbConnectionLike {
|
|
11
10
|
/** {@inheritDoc} */
|
|
12
11
|
protected _props: CbConnProps;
|
|
13
12
|
protected constructor(opt?: CbConnOpt);
|
|
@@ -28,9 +27,9 @@ export declare abstract class CbConnection extends DbConnection<CbRepoDef, Query
|
|
|
28
27
|
/** {@inheritDoc} */
|
|
29
28
|
castDatesForList<T>(given: Array<ReplaceType<T, Date, string> | T>, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
|
|
30
29
|
/** {@inheritDoc} */
|
|
31
|
-
more<T>(
|
|
30
|
+
more<T>(link: CbRepoLink, lines: string | DbLines, p1?: string | CbExecOpt): Promise<DbQueryResultMore<T, QueryMetaData>>;
|
|
32
31
|
/** {@inheritDoc} */
|
|
33
|
-
one<T>(
|
|
32
|
+
one<T>(link: CbRepoLink, lines: string | DbLines, p1?: string | CbExecOpt): Promise<DbQueryResultOne<T, QueryMetaData>>;
|
|
34
33
|
/** {@inheritDoc} */
|
|
35
34
|
connect(): Promise<boolean>;
|
|
36
35
|
/** {@inheritDoc} */
|
|
@@ -160,15 +160,15 @@ class CbConnection extends be_db_common_1.DbConnection {
|
|
|
160
160
|
// endregion transcoders
|
|
161
161
|
// region query
|
|
162
162
|
/** {@inheritDoc} */
|
|
163
|
-
more(
|
|
163
|
+
more(link, lines, p1) {
|
|
164
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
165
|
const opt = this.buildOpt(p1);
|
|
166
166
|
const sql = (0, type_1.isObjectValid)(lines) ? lines.end() : lines;
|
|
167
167
|
if (opt.printSql) {
|
|
168
|
-
this.logger.log(`${
|
|
168
|
+
this.logger.log(`${link.path} > SQL${opt.name}`, sql);
|
|
169
169
|
}
|
|
170
170
|
try {
|
|
171
|
-
const result = yield
|
|
171
|
+
const result = yield link.scope.query(sql, opt);
|
|
172
172
|
return {
|
|
173
173
|
success: true,
|
|
174
174
|
rows: result.rows,
|
|
@@ -186,15 +186,15 @@ class CbConnection extends be_db_common_1.DbConnection {
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
/** {@inheritDoc} */
|
|
189
|
-
one(
|
|
189
|
+
one(link, lines, p1) {
|
|
190
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
191
191
|
const opt = this.buildOpt(p1);
|
|
192
192
|
const sql = (0, type_1.isObjectValid)(lines) ? lines.end() : lines;
|
|
193
193
|
if (opt.printSql) {
|
|
194
|
-
this.logger.log(`${
|
|
194
|
+
this.logger.log(`${link.path} > SQL${opt.name}`, sql);
|
|
195
195
|
}
|
|
196
196
|
try {
|
|
197
|
-
const result = yield
|
|
197
|
+
const result = yield link.scope.query(sql, opt);
|
|
198
198
|
return {
|
|
199
199
|
success: true,
|
|
200
200
|
row: (Array.isArray(result.rows) && result.rows.length > 0) ? result.rows[0] : undefined,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Cluster, QueryMetaData, QueryOptions, QueryResult } from "couchbase";
|
|
2
|
-
import type { IgnoreFieldsByType, KeyValue, ReplaceType } from "@leyyo/common";
|
|
3
|
-
import type {
|
|
4
|
-
import type { DbConnectionLike, DbConnOpt, DbConnProps, DbExecOpt } from "@samet-it/be-db-common";
|
|
5
|
-
import type { DefDims, Entity, UrnDocLike, Pair, Portion, View } from "@samet-it/be-base-common";
|
|
1
|
+
import type { Cluster, QueryMetaData, QueryOptions, QueryResult, Scope } from "couchbase";
|
|
2
|
+
import type { IgnoreFieldsByType, KeyValue, ReplaceType, StrKey } from "@leyyo/common";
|
|
3
|
+
import type { CbRepoDirectOpt, CbRepoLike } from "../repo";
|
|
4
|
+
import type { DbConnectionLike, DbConnOpt, DbConnProps, DbExecOpt, DbRepoLink } from "@samet-it/be-db-common";
|
|
5
|
+
import type { DefDims, Entity, UrnDocLike, Pair, Portion, View, UrnDef } from "@samet-it/be-base-common";
|
|
6
6
|
/**
|
|
7
7
|
* Couchbase connection interface
|
|
8
8
|
* */
|
|
9
|
-
export interface CbConnectionLike extends DbConnectionLike<
|
|
9
|
+
export interface CbConnectionLike extends DbConnectionLike<CbRepoLink, QueryMetaData, CbExecOpt> {
|
|
10
10
|
/** @inheritDoc */
|
|
11
11
|
get props(): Readonly<CbConnProps>;
|
|
12
12
|
/**
|
|
@@ -81,7 +81,7 @@ export interface CbDirectConnectionLike extends CbConnectionLike {
|
|
|
81
81
|
* @param {CbRepoDirectOpt} opt - options
|
|
82
82
|
* @return {CbRepoLike} - created repository
|
|
83
83
|
* */
|
|
84
|
-
newRepo<
|
|
84
|
+
newRepo<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef, KEYS extends string = StrKey<ENTITY>, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = ENTITY, PORTION extends Portion<ID> = Portion<ID>, R = unknown>(opt: CbRepoDirectOpt<ENTITY, ID, URN, DIMS, R>): CbRepoLike<ENTITY, ID, URN, KEYS, DIMS, PAIR, VIEW, PORTION>;
|
|
85
85
|
}
|
|
86
86
|
export type CbIgnoreDate<T> = CbReplaceType<T, Date, string>;
|
|
87
87
|
export type CbIgnoreDateKeys<T> = CbIgnoreFields<T, Date>;
|
|
@@ -91,4 +91,7 @@ type CbIgnoreFields<T, I> = {
|
|
|
91
91
|
type CbReplaceType<T, O, N> = {
|
|
92
92
|
[P in keyof T]: T[P] extends O ? N : T[P];
|
|
93
93
|
};
|
|
94
|
+
export interface CbRepoLink extends DbRepoLink {
|
|
95
|
+
scope: Scope;
|
|
96
|
+
}
|
|
94
97
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CbRepo } from "./cb.repo";
|
|
2
|
-
import type { DefDims, Entity, Pair, Portion, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
2
|
+
import type { DefDims, Entity, Pair, Portion, UrnDef, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
3
3
|
import type { CbConnectionLike } from "../connection";
|
|
4
4
|
import type { CbRepoDirectOpt } from "./index.types";
|
|
5
|
-
import type { KeyValue } from "@leyyo/common";
|
|
5
|
+
import type { KeyValue, StrKey } from "@leyyo/common";
|
|
6
6
|
/**
|
|
7
7
|
* Couchbase repository direct class
|
|
8
8
|
* */
|
|
9
|
-
export declare class CbDirectRepo<
|
|
10
|
-
constructor(conn: CbConnectionLike, opt: CbRepoDirectOpt<
|
|
9
|
+
export declare class CbDirectRepo<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, KEYS extends string = StrKey<ENTITY>, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = ENTITY, PORTION extends Portion<ID> = Portion<ID>> extends CbRepo<ENTITY, ID, URN, KEYS, DIMS, PAIR, VIEW, PORTION> {
|
|
10
|
+
constructor(conn: CbConnectionLike, opt: CbRepoDirectOpt<ENTITY, ID, URN, DIMS>);
|
|
11
11
|
}
|
package/dist/repo/cb.repo.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { CbConnectionLike, CbExecOpt } from "../connection";
|
|
2
2
|
import type { KeyValue } from "@leyyo/common";
|
|
3
3
|
import type { StrKey } from "@leyyo/common";
|
|
4
|
-
import type { CbExistsOpt, CbGetOpt, CbInsertOpt, CbReplaceOpt,
|
|
4
|
+
import type { CbExistsOpt, CbGetOpt, CbInsertOpt, CbReplaceOpt, CbRepoProps, CbRepoLike, CbRepoOpt } from "./index.types";
|
|
5
5
|
import { DbRepo } from "@samet-it/be-db-common";
|
|
6
|
-
import type { DefDims, Entity, Pair, Portion, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
6
|
+
import type { DefDims, Entity, Pair, Portion, UrnDef, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
7
7
|
import type { QueryRegular } from "@leyyo/query";
|
|
8
8
|
/**
|
|
9
9
|
* Couchbase repository abstract class
|
|
10
10
|
* */
|
|
11
|
-
export declare abstract class CbRepo<
|
|
11
|
+
export declare abstract class CbRepo<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, KEYS extends string = StrKey<ENTITY>, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = ENTITY, PORTION extends Portion<ID> = Portion<ID>> extends DbRepo<CbConnectionLike, CbExecOpt, ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> implements CbRepoLike<ENTITY, ID, URN, KEYS, DIMS, PAIR, VIEW, PORTION> {
|
|
12
12
|
private static _specs;
|
|
13
13
|
/** @inheritDoc */
|
|
14
|
-
protected _props: CbRepoProps<
|
|
15
|
-
protected constructor(conn: CbConnectionLike, opt?: CbRepoOpt<
|
|
14
|
+
protected _props: CbRepoProps<ENTITY, ID>;
|
|
15
|
+
protected constructor(conn: CbConnectionLike, opt?: CbRepoOpt<ENTITY, ID>);
|
|
16
16
|
/**
|
|
17
17
|
* Check property name
|
|
18
18
|
*
|
|
@@ -65,9 +65,7 @@ export declare abstract class CbRepo<ID extends KeyValue, ENTITY extends Entity<
|
|
|
65
65
|
* */
|
|
66
66
|
protected $createIndices(): Promise<void>;
|
|
67
67
|
/** @inheritDoc */
|
|
68
|
-
get
|
|
69
|
-
/** @inheritDoc */
|
|
70
|
-
get props(): Readonly<CbRepoProps<ID, ENTITY>>;
|
|
68
|
+
get props(): Readonly<CbRepoProps<ENTITY, ID>>;
|
|
71
69
|
/** @inheritDoc */
|
|
72
70
|
$getByPrimary(key: string, p1?: CbGetOpt | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
|
|
73
71
|
/** @inheritDoc */
|
package/dist/repo/cb.repo.js
CHANGED
|
@@ -92,7 +92,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
92
92
|
}
|
|
93
93
|
name = this._indexName(name);
|
|
94
94
|
sql = `CREATE INDEX ${conn.f(name)} ON ${full} (${fields.join(', ')}) IF NOT EXISTS`;
|
|
95
|
-
yield conn.one(this
|
|
95
|
+
yield conn.one(this._props, sql, {
|
|
96
96
|
name: `${path}.index`,
|
|
97
97
|
ignoredErrors: [couchbase_1.IndexExistsError.name]
|
|
98
98
|
});
|
|
@@ -129,7 +129,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
129
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
130
|
const { full, path, conn } = this._props;
|
|
131
131
|
const sql = `CREATE PRIMARY INDEX \`pk\` ON ${full} IF NOT EXISTS`;
|
|
132
|
-
yield conn.one(this
|
|
132
|
+
yield conn.one(this._props, sql, {
|
|
133
133
|
name: `${path}.pk`,
|
|
134
134
|
ignoredErrors: [couchbase_1.IndexExistsError.name]
|
|
135
135
|
});
|
|
@@ -226,10 +226,6 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
226
226
|
// endregion protected-method
|
|
227
227
|
// region getter
|
|
228
228
|
/** @inheritDoc */
|
|
229
|
-
get $def() {
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
/** @inheritDoc */
|
|
233
229
|
get props() {
|
|
234
230
|
return this._props;
|
|
235
231
|
}
|
|
@@ -259,7 +255,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
259
255
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
260
256
|
.add('LIMIT 1');
|
|
261
257
|
const parameters = { key };
|
|
262
|
-
return (yield conn.one(this
|
|
258
|
+
return (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row;
|
|
263
259
|
});
|
|
264
260
|
}
|
|
265
261
|
/** @inheritDoc */
|
|
@@ -283,7 +279,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
283
279
|
.no(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`)
|
|
284
280
|
.add('LIMIT 1');
|
|
285
281
|
const parameters = { key };
|
|
286
|
-
return (yield conn.one(this
|
|
282
|
+
return (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row;
|
|
287
283
|
});
|
|
288
284
|
}
|
|
289
285
|
// endregion get
|
|
@@ -308,7 +304,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
308
304
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
309
305
|
.add('LIMIT 1');
|
|
310
306
|
const parameters = { key };
|
|
311
|
-
return ((_c = (yield conn.one(this
|
|
307
|
+
return ((_c = (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _c === void 0 ? void 0 : _c.x) === undefined;
|
|
312
308
|
});
|
|
313
309
|
}
|
|
314
310
|
/** @inheritDoc */
|
|
@@ -333,7 +329,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
333
329
|
.yes(useSoftDelete, `WHERE (a.${F_TRASH_ID} IS MISSING)`)
|
|
334
330
|
.add('LIMIT 1');
|
|
335
331
|
const parameters = { key };
|
|
336
|
-
return ((_a = (yield conn.one(this
|
|
332
|
+
return ((_a = (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x) === undefined;
|
|
337
333
|
});
|
|
338
334
|
}
|
|
339
335
|
// endregion exists
|
|
@@ -356,7 +352,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
356
352
|
.add(`USE KEYS $keys`)
|
|
357
353
|
.yes(useSoftDelete, `WHERE (a.${F_TRASH_ID} is missing)`);
|
|
358
354
|
const parameters = { keys };
|
|
359
|
-
return (yield conn.more(this
|
|
355
|
+
return (yield conn.more(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).rows;
|
|
360
356
|
});
|
|
361
357
|
}
|
|
362
358
|
/** @inheritDoc */
|
|
@@ -382,7 +378,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
382
378
|
.add(`WHERE (a.${F_ID} IN $keys)`)
|
|
383
379
|
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} IS MISSING)`);
|
|
384
380
|
const parameters = { keys };
|
|
385
|
-
return (yield conn.more(this
|
|
381
|
+
return (yield conn.more(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).rows;
|
|
386
382
|
});
|
|
387
383
|
}
|
|
388
384
|
// endregion list
|
|
@@ -398,7 +394,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
398
394
|
.add(`SELECT a.*`)
|
|
399
395
|
.add(`FROM ${full} a`)
|
|
400
396
|
.both(useSoftDelete, `WHERE (a.${F_TRASH_ID} is missing)`, `WHERE (meta().id is not missing)`);
|
|
401
|
-
return (yield conn.more(this
|
|
397
|
+
return (yield conn.more(this._props, lines.end(), opt)).rows;
|
|
402
398
|
});
|
|
403
399
|
}
|
|
404
400
|
// endregion filter
|
|
@@ -481,7 +477,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
481
477
|
}
|
|
482
478
|
lines
|
|
483
479
|
.yes(useSoftDelete, `WHERE (a.${F_TRASH_ID} is missing)`);
|
|
484
|
-
yield conn.one(this
|
|
480
|
+
yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }));
|
|
485
481
|
return key;
|
|
486
482
|
}
|
|
487
483
|
return undefined;
|
|
@@ -530,7 +526,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
530
526
|
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`);
|
|
531
527
|
parameters['key'] = key;
|
|
532
528
|
lines.add('RETURNING meta().id \`x\`');
|
|
533
|
-
return (_a = (yield conn.one(this
|
|
529
|
+
return (_a = (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x;
|
|
534
530
|
}
|
|
535
531
|
return undefined;
|
|
536
532
|
});
|
|
@@ -556,7 +552,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
556
552
|
.add(`USE KEYS $key`)
|
|
557
553
|
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`);
|
|
558
554
|
const parameters = { key };
|
|
559
|
-
yield conn.one(this
|
|
555
|
+
yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }));
|
|
560
556
|
return key;
|
|
561
557
|
});
|
|
562
558
|
}
|
|
@@ -582,7 +578,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
582
578
|
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`)
|
|
583
579
|
.add('RETURNING meta().id \`x\`');
|
|
584
580
|
const parameters = { key };
|
|
585
|
-
return (_a = (yield conn.one(this
|
|
581
|
+
return (_a = (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x;
|
|
586
582
|
});
|
|
587
583
|
}
|
|
588
584
|
// endregion remove
|
|
@@ -611,7 +607,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
611
607
|
trashId: opt.trashId,
|
|
612
608
|
key,
|
|
613
609
|
};
|
|
614
|
-
yield conn.one(this
|
|
610
|
+
yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }));
|
|
615
611
|
return key;
|
|
616
612
|
});
|
|
617
613
|
}
|
|
@@ -646,7 +642,7 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
646
642
|
trashId: opt.trashId,
|
|
647
643
|
key,
|
|
648
644
|
};
|
|
649
|
-
return (_a = (yield conn.one(this
|
|
645
|
+
return (_a = (yield conn.one(this._props, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x;
|
|
650
646
|
});
|
|
651
647
|
}
|
|
652
648
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Bucket, BucketSettings, Cluster, Collection, CollectionSpec, RemoveOptions, Scope, ScopeSpec } from "couchbase";
|
|
2
2
|
import type { CbConnectionLike, CbExecOpt } from "../connection";
|
|
3
3
|
import type { DbRepoLike, DbRepoOpt, DbRepoToDim, DbRepoToUrnTuple } from "@samet-it/be-db-common";
|
|
4
|
-
import type { DefDims, Entity, Pair, Portion, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
4
|
+
import type { DefDims, Entity, Pair, Portion, UrnDef, UrnDocLike, View } from "@samet-it/be-base-common";
|
|
5
5
|
import type { ExistsOptions, GetOptions, InsertOptions, ReplaceOptions } from "couchbase";
|
|
6
6
|
import type { DbRepoProps } from "@samet-it/be-db-common";
|
|
7
|
-
import type { KeyValue } from "@leyyo/common";
|
|
7
|
+
import type { KeyValue, StrKey } from "@leyyo/common";
|
|
8
8
|
/**
|
|
9
9
|
* General result for mutable queries to return key
|
|
10
10
|
* */
|
|
@@ -18,11 +18,9 @@ export interface CbResultX {
|
|
|
18
18
|
* Couchbase repository (collection) interface
|
|
19
19
|
* @abstract
|
|
20
20
|
* */
|
|
21
|
-
export interface CbRepoLike<
|
|
21
|
+
export interface CbRepoLike<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, KEYS extends string = StrKey<ENTITY>, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = ENTITY, PORTION extends Portion<ID> = Portion<ID>> extends DbRepoLike<CbConnectionLike, CbExecOpt, ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> {
|
|
22
22
|
/** @inheritDoc */
|
|
23
|
-
get
|
|
24
|
-
/** @inheritDoc */
|
|
25
|
-
get props(): Readonly<CbRepoProps<ID, ENTITY>>;
|
|
23
|
+
get props(): Readonly<CbRepoProps<ENTITY, ID>>;
|
|
26
24
|
/** @inheritDoc */
|
|
27
25
|
insert(doc: ENTITY, opt?: CbInsertOpt | string, ignoreCheck?: boolean): Promise<string>;
|
|
28
26
|
/** @inheritDoc */
|
|
@@ -44,14 +42,10 @@ export interface CbRepoLike<ID extends KeyValue, ENTITY extends Entity<ID>, URN
|
|
|
44
42
|
/** @inheritDoc */
|
|
45
43
|
$removeBySecondary(key: KeyValue, opt?: CbRemoveOpt | string, ignoreCheck?: boolean): Promise<string>;
|
|
46
44
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Couchbase default repository (collection) without any generics
|
|
49
|
-
* */
|
|
50
|
-
export type CbRepoDef = CbRepoLike<KeyValue, Entity<KeyValue>, UrnDocLike>;
|
|
51
45
|
/**
|
|
52
46
|
* Couchbase repository (collection) option
|
|
53
47
|
* */
|
|
54
|
-
export interface CbRepoOpt<
|
|
48
|
+
export interface CbRepoOpt<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue> extends DbRepoOpt<ID, ENTITY> {
|
|
55
49
|
/**
|
|
56
50
|
* Bucket name
|
|
57
51
|
*
|
|
@@ -80,7 +74,7 @@ export interface CbRepoOpt<ID extends KeyValue, ENTITY extends Entity<ID>> exten
|
|
|
80
74
|
/**
|
|
81
75
|
* Couchbase repository (collection) props
|
|
82
76
|
* */
|
|
83
|
-
export interface CbRepoProps<
|
|
77
|
+
export interface CbRepoProps<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue> extends CbRepoOpt<ENTITY, ID>, DbRepoProps<CbConnectionLike, ID, ENTITY> {
|
|
84
78
|
/**
|
|
85
79
|
* Cluster
|
|
86
80
|
*
|
|
@@ -124,7 +118,7 @@ export interface CbRepoPropsPart<S> {
|
|
|
124
118
|
/**
|
|
125
119
|
* Couchbase direct repository (collection) option
|
|
126
120
|
* */
|
|
127
|
-
export interface CbRepoDirectOpt<
|
|
121
|
+
export interface CbRepoDirectOpt<ENTITY extends Entity<ID>, ID extends KeyValue = KeyValue, URN extends UrnDocLike = UrnDef<ID>, DIMS extends DefDims = DefDims, R = unknown> extends CbRepoOpt<ENTITY, ID> {
|
|
128
122
|
/**
|
|
129
123
|
* Name of logger class
|
|
130
124
|
* */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-couchbase-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Couchbase common component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Couchbase"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@leyyo/type": "^1.1.1",
|
|
73
73
|
"@samet-it/be-base-common": "^1.1.1",
|
|
74
74
|
"@samet-it/be-cache-common": "^1.1.1",
|
|
75
|
-
"@samet-it/be-db-common": "^1.1.
|
|
75
|
+
"@samet-it/be-db-common": "^1.1.2",
|
|
76
76
|
"couchbase": "^4.6.0"
|
|
77
77
|
}
|
|
78
78
|
}
|