@samet-it/be-couchbase-common 1.0.2 → 1.0.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/adapter/cb-adapter.service.d.ts +7 -10
- package/dist/adapter/cb-adapter.service.js +61 -69
- package/dist/adapter/index.types.d.ts +38 -28
- package/dist/config/couchbase-common.config.js +2 -1
- package/dist/line/cb-line.impl.d.ts +1 -1
- package/dist/line/cb-line.impl.js +29 -0
- package/dist/line/index.types.d.ts +5 -1
- package/dist/repo/cb.repo.d.ts +16 -39
- package/dist/repo/cb.repo.js +43 -111
- package/dist/repo/index.types.d.ts +20 -50
- package/package.json +3 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type IgnoreFieldsByType, type ReplaceType } from "@leyyo/common";
|
|
2
|
-
import { type QueryOptions } from 'couchbase';
|
|
3
1
|
import { Cluster, Collection, QueryResult } from 'couchbase';
|
|
4
|
-
import type {
|
|
2
|
+
import type { IgnoreFieldsByType, ReplaceType } from "@leyyo/common";
|
|
3
|
+
import type { CbAdapterServiceLike, CbEntity, CbExecOpt, CbQueryResultMore, CbQueryResultOne } from "./index.types";
|
|
5
4
|
import type { CbRepoDef } from "../repo";
|
|
6
5
|
export declare class CbAdapterService implements CbAdapterServiceLike {
|
|
7
6
|
private readonly _CLEAR_ERROR_INTERVAL;
|
|
@@ -28,6 +27,7 @@ export declare class CbAdapterService implements CbAdapterServiceLike {
|
|
|
28
27
|
* Build json format of CB object
|
|
29
28
|
* */
|
|
30
29
|
private _toJson;
|
|
30
|
+
protected _checkError(err: Error, opt: CbExecOpt): void;
|
|
31
31
|
/** {@inheritDoc} */
|
|
32
32
|
f(field: string): string;
|
|
33
33
|
/** {@inheritDoc} */
|
|
@@ -57,14 +57,11 @@ export declare class CbAdapterService implements CbAdapterServiceLike {
|
|
|
57
57
|
castDates<T>(given: ReplaceType<T, Date, string> | T, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
|
|
58
58
|
/** {@inheritDoc} */
|
|
59
59
|
castDatesForList<T>(given: Array<ReplaceType<T, Date, string> | T>, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
|
|
60
|
-
|
|
61
|
-
exec2<T>(repo: CbRepoDef, sql: string, opt?: CbExecOpt): Promise<Array<T>>;
|
|
62
|
-
exec2First<T>(repo: CbRepoDef, sql: string, opt?: CbExecOpt): Promise<T | undefined>;
|
|
63
|
-
execExtended<T>(repo: CbRepoDef, sql: string, query: QueryOptions, opt?: CbExecOpt): Promise<Array<T>>;
|
|
64
|
-
execFirstExtended<T>(repo: CbRepoDef, sql: string, query: QueryOptions, opt?: CbExecOpt): Promise<T | undefined>;
|
|
65
|
-
exec1<T>(repo: CbRepoDef, fn: Promise<T>, opt?: CbExecOpt): Promise<T>;
|
|
60
|
+
buildOpt(p1?: string | Partial<CbExecOpt>, name?: string): CbExecOpt;
|
|
66
61
|
/** {@inheritDoc} */
|
|
67
|
-
exec<T>(
|
|
62
|
+
exec<T>(fn: Promise<T>, p1?: string | Omit<CbExecOpt, 'printSql'>): Promise<T>;
|
|
63
|
+
more<T>(repo: CbRepoDef, sql: string, p1?: string | CbExecOpt): Promise<CbQueryResultMore<T>>;
|
|
64
|
+
one<T>(repo: CbRepoDef, sql: string, p1?: string | CbExecOpt): Promise<CbQueryResultOne<T>>;
|
|
68
65
|
/** {@inheritDoc} */
|
|
69
66
|
connectDb(): Promise<Cluster>;
|
|
70
67
|
}
|
|
@@ -55,7 +55,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
55
55
|
exports.CbAdapterService = void 0;
|
|
56
56
|
const couchbase = __importStar(require("couchbase"));
|
|
57
57
|
const common_1 = require("@nestjs/common");
|
|
58
|
-
const common_2 = require("@leyyo/common");
|
|
59
58
|
const couchbase_1 = require("couchbase");
|
|
60
59
|
const config_1 = require("../config");
|
|
61
60
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -87,15 +86,10 @@ let CbAdapterService = class CbAdapterService {
|
|
|
87
86
|
* */
|
|
88
87
|
_ping() {
|
|
89
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
var _a;
|
|
91
89
|
try {
|
|
92
|
-
yield this.exec({
|
|
93
|
-
name: 'ping',
|
|
94
|
-
promise: this._cluster.ping()
|
|
95
|
-
});
|
|
90
|
+
yield this.exec(this._cluster.ping(), { name: 'ping' });
|
|
96
91
|
}
|
|
97
92
|
catch (err) {
|
|
98
|
-
this.logger.error(`!ping[${(_a = err.name) !== null && _a !== void 0 ? _a : ''}]`, err);
|
|
99
93
|
}
|
|
100
94
|
setTimeout(() => this._ping(), 30000);
|
|
101
95
|
});
|
|
@@ -159,6 +153,21 @@ let CbAdapterService = class CbAdapterService {
|
|
|
159
153
|
return 'null';
|
|
160
154
|
}
|
|
161
155
|
}
|
|
156
|
+
_checkError(err, opt) {
|
|
157
|
+
var _a;
|
|
158
|
+
if (!this._nativeErrors.has(err)) {
|
|
159
|
+
this._nativeErrors.set(err, 1);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this._nativeErrors.set(err, this._nativeErrors.get(err) + 1);
|
|
163
|
+
}
|
|
164
|
+
if ((_a = opt === null || opt === void 0 ? void 0 : opt.ignoredErrors) === null || _a === void 0 ? void 0 : _a.includes(err)) {
|
|
165
|
+
this.logger.warn(`${opt.name} => (${err.name})${err.message}`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.logger.error(`${opt.name} => (${err.name})${err.message}`, JSON.stringify(err.context));
|
|
169
|
+
throw err;
|
|
170
|
+
}
|
|
162
171
|
/** {@inheritDoc} */
|
|
163
172
|
f(field) {
|
|
164
173
|
if (field.includes('.')) {
|
|
@@ -329,89 +338,72 @@ let CbAdapterService = class CbAdapterService {
|
|
|
329
338
|
const arr = given;
|
|
330
339
|
arr.forEach(item => this.castDates(item, ...fields));
|
|
331
340
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
this._nativeErrors.set(err, this._nativeErrors.get(err) + 1);
|
|
339
|
-
}
|
|
340
|
-
if ((_a = opt === null || opt === void 0 ? void 0 : opt.ignoredErrors) === null || _a === void 0 ? void 0 : _a.includes(err)) {
|
|
341
|
-
return undefined;
|
|
341
|
+
buildOpt(p1, name) {
|
|
342
|
+
const opt = typeof p1 === 'string' ? { name: p1 } : Object.assign({}, p1);
|
|
343
|
+
if (typeof opt.name === undefined && typeof name !== undefined) {
|
|
344
|
+
opt.name = name;
|
|
342
345
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
exec2(repo, sql, opt) {
|
|
347
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
-
return this.execExtended(repo, sql, undefined, opt);
|
|
349
|
-
});
|
|
346
|
+
opt.name = opt.name ? `[${opt.name}]` : '';
|
|
347
|
+
return opt;
|
|
350
348
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return this.first(yield this.exec2(repo, sql, opt));
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
execExtended(repo, sql, query, opt) {
|
|
349
|
+
/** {@inheritDoc} */
|
|
350
|
+
exec(fn, p1) {
|
|
357
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
358
|
-
const
|
|
359
|
-
if (opt === null || opt === void 0 ? void 0 : opt.printSql) {
|
|
360
|
-
this.logger.log(`${repo.path} > SQL${op}`, sql);
|
|
361
|
-
}
|
|
352
|
+
const opt = this.buildOpt(p1);
|
|
362
353
|
try {
|
|
363
|
-
return
|
|
354
|
+
return yield fn;
|
|
364
355
|
}
|
|
365
356
|
catch (err) {
|
|
366
|
-
|
|
357
|
+
this._checkError(err, opt);
|
|
358
|
+
return undefined;
|
|
367
359
|
}
|
|
368
360
|
});
|
|
369
361
|
}
|
|
370
|
-
|
|
362
|
+
more(repo, sql, p1) {
|
|
371
363
|
return __awaiter(this, void 0, void 0, function* () {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
-
const op = (opt === null || opt === void 0 ? void 0 : opt.name) ? `[${opt.name}]` : '';
|
|
378
|
-
common_2.$assert.object(fn, () => {
|
|
379
|
-
return { field: 'fn', where: 'CbAdapterService', path: repo.path, op: op };
|
|
380
|
-
});
|
|
381
|
-
common_2.$assert.func(fn.then, () => {
|
|
382
|
-
return { field: 'fn.then', where: 'CbAdapterService', path: repo.path, op: op };
|
|
383
|
-
});
|
|
364
|
+
const opt = this.buildOpt(p1);
|
|
365
|
+
if (opt.printSql) {
|
|
366
|
+
this.logger.log(`${repo.path} > SQL${opt.name}`, sql);
|
|
367
|
+
}
|
|
384
368
|
try {
|
|
385
|
-
|
|
369
|
+
const result = yield repo.scope.query(sql, opt);
|
|
370
|
+
return {
|
|
371
|
+
success: true,
|
|
372
|
+
rows: result.rows,
|
|
373
|
+
meta: result.meta,
|
|
374
|
+
};
|
|
386
375
|
}
|
|
387
376
|
catch (err) {
|
|
388
|
-
|
|
377
|
+
this._checkError(err, opt);
|
|
378
|
+
return {
|
|
379
|
+
success: false,
|
|
380
|
+
rows: [],
|
|
381
|
+
error: err,
|
|
382
|
+
};
|
|
389
383
|
}
|
|
390
384
|
});
|
|
391
385
|
}
|
|
392
|
-
|
|
393
|
-
exec(opt) {
|
|
386
|
+
one(repo, sql, p1) {
|
|
394
387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
|
|
396
|
-
|
|
388
|
+
const opt = this.buildOpt(p1);
|
|
389
|
+
if (opt.printSql) {
|
|
390
|
+
this.logger.log(`${repo.path} > SQL${opt.name}`, sql);
|
|
397
391
|
}
|
|
398
392
|
try {
|
|
399
|
-
|
|
393
|
+
const result = yield repo.scope.query(sql, opt);
|
|
394
|
+
return {
|
|
395
|
+
success: true,
|
|
396
|
+
row: (Array.isArray(result.rows) && result.rows.length > 0) ? result.rows[0] : undefined,
|
|
397
|
+
meta: result.meta,
|
|
398
|
+
};
|
|
400
399
|
}
|
|
401
400
|
catch (err) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
if (Array.isArray(opt.ignoredErrors) && opt.ignoredErrors.includes(e)) {
|
|
410
|
-
return undefined;
|
|
411
|
-
}
|
|
412
|
-
const op = opt.name ? `[${opt.name}] ` : '';
|
|
413
|
-
this.logger.error(`${op}${err.message}`, err);
|
|
414
|
-
throw err;
|
|
401
|
+
this._checkError(err, opt);
|
|
402
|
+
return {
|
|
403
|
+
success: false,
|
|
404
|
+
row: undefined,
|
|
405
|
+
error: err,
|
|
406
|
+
};
|
|
415
407
|
}
|
|
416
408
|
});
|
|
417
409
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Scope, Cluster, Collection, QueryResult, QueryOptions, QueryMetaData } from "couchbase";
|
|
2
2
|
import type { IgnoreFieldsByType, ReplaceType } from "@leyyo/common";
|
|
3
3
|
import type { CbRepoDef } from "../repo";
|
|
4
|
+
import { CouchbaseError } from "couchbase/dist/errors";
|
|
4
5
|
export interface CbAdapterServiceLike {
|
|
5
6
|
/**
|
|
6
7
|
* Field name
|
|
@@ -74,22 +75,49 @@ export interface CbAdapterServiceLike {
|
|
|
74
75
|
* Cast dates for an array
|
|
75
76
|
* */
|
|
76
77
|
castDatesForList<T>(given: Array<ReplaceType<T, Date, string> | T>, ...fields: Array<IgnoreFieldsByType<T, Date>>): void;
|
|
78
|
+
buildOpt(): CbExecOpt;
|
|
79
|
+
buildOpt(name: string): CbExecOpt;
|
|
80
|
+
buildOpt(opt: Partial<CbExecOpt>, name?: string): CbExecOpt;
|
|
81
|
+
exec<T>(fn: Promise<T>): Promise<T>;
|
|
82
|
+
exec<T>(fn: Promise<T>, name: string): Promise<T>;
|
|
83
|
+
exec<T>(fn: Promise<T>, opt: Omit<CbExecOpt, 'printSql'>): Promise<T>;
|
|
77
84
|
/**
|
|
78
85
|
* Execute an sql
|
|
79
86
|
* */
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
execExtended<T>(repo: CbRepoDef, sql: string, query: QueryOptions, opt?: CbExecOpt): Promise<Array<T>>;
|
|
87
|
-
execFirstExtended<T>(repo: CbRepoDef, sql: string, query: QueryOptions, opt?: CbExecOpt): Promise<T | undefined>;
|
|
87
|
+
more<T>(repo: CbRepoDef, sql: string): Promise<CbQueryResultMore<T>>;
|
|
88
|
+
more<T>(repo: CbRepoDef, sql: string, name: string): Promise<CbQueryResultMore<T>>;
|
|
89
|
+
more<T>(repo: CbRepoDef, sql: string, opt: CbExecOpt): Promise<CbQueryResultMore<T>>;
|
|
90
|
+
one<T>(repo: CbRepoDef, sql: string): Promise<CbQueryResultOne<T>>;
|
|
91
|
+
one<T>(repo: CbRepoDef, sql: string, name: string): Promise<CbQueryResultOne<T>>;
|
|
92
|
+
one<T>(repo: CbRepoDef, sql: string, opt?: CbExecOpt): Promise<CbQueryResultOne<T>>;
|
|
88
93
|
/**
|
|
89
94
|
* Connect to DB
|
|
90
95
|
* */
|
|
91
96
|
connectDb(): Promise<Cluster>;
|
|
92
97
|
}
|
|
98
|
+
export declare class CbQueryResult {
|
|
99
|
+
success: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* [when success=true] The meta-data which has been returned by the query.
|
|
102
|
+
*/
|
|
103
|
+
meta?: QueryMetaData;
|
|
104
|
+
/**
|
|
105
|
+
* [when success=false] Couchbase error
|
|
106
|
+
*/
|
|
107
|
+
error?: CouchbaseError;
|
|
108
|
+
}
|
|
109
|
+
export declare class CbQueryResultOne<E = any> extends CbQueryResult {
|
|
110
|
+
/**
|
|
111
|
+
* The rows which have been returned by the query.
|
|
112
|
+
*/
|
|
113
|
+
row: E | undefined;
|
|
114
|
+
}
|
|
115
|
+
export declare class CbQueryResultMore<E = any> extends CbQueryResult {
|
|
116
|
+
/**
|
|
117
|
+
* The rows which have been returned by the query.
|
|
118
|
+
*/
|
|
119
|
+
rows: E[];
|
|
120
|
+
}
|
|
93
121
|
export interface CbEntity {
|
|
94
122
|
/**
|
|
95
123
|
* Id
|
|
@@ -123,21 +151,7 @@ type CbIgnoreFields<T, I> = {
|
|
|
123
151
|
type CbReplaceType<T, O, N> = {
|
|
124
152
|
[P in keyof T]: T[P] extends O ? N : T[P];
|
|
125
153
|
};
|
|
126
|
-
export interface
|
|
127
|
-
/**
|
|
128
|
-
* Promise function
|
|
129
|
-
* */
|
|
130
|
-
promise: Promise<T>;
|
|
131
|
-
/**
|
|
132
|
-
* Name of SQL
|
|
133
|
-
* */
|
|
134
|
-
name?: string;
|
|
135
|
-
/**
|
|
136
|
-
* Ignored errors
|
|
137
|
-
* */
|
|
138
|
-
ignoredErrors?: Omit<Error, 'message'> | Array<Omit<Error, 'message'>>;
|
|
139
|
-
}
|
|
140
|
-
export interface CbExecMutationOpt {
|
|
154
|
+
export interface CbExecOpt extends QueryOptions {
|
|
141
155
|
/**
|
|
142
156
|
* Name of SQL
|
|
143
157
|
* */
|
|
@@ -146,14 +160,10 @@ export interface CbExecMutationOpt {
|
|
|
146
160
|
* Ignored errors
|
|
147
161
|
* */
|
|
148
162
|
ignoredErrors?: CbError[];
|
|
149
|
-
}
|
|
150
|
-
export interface CbExecOpt extends CbExecMutationOpt {
|
|
151
163
|
/**
|
|
152
164
|
* Name of SQL
|
|
153
165
|
* */
|
|
154
166
|
printSql?: string;
|
|
155
|
-
}
|
|
156
|
-
export interface CbExecTrashOpt extends CbExecOpt {
|
|
157
167
|
trashId?: string;
|
|
158
168
|
}
|
|
159
169
|
export type CbIgnoreDate<T> = CbReplaceType<T, Date, string>;
|
|
@@ -4,10 +4,11 @@ exports.couchbaseCommonConfig = void 0;
|
|
|
4
4
|
const env_1 = require("@leyyo/env");
|
|
5
5
|
exports.couchbaseCommonConfig = env_1.envCore.configure
|
|
6
6
|
.scope('CouchbaseCommon')
|
|
7
|
+
.begin
|
|
7
8
|
.field('CB_HOST').text().required().end
|
|
8
9
|
.field('CB_USER').text().required().end
|
|
9
10
|
.field('CB_PASS').text().required().end
|
|
10
11
|
.field('CB_BUCKET').text().required().end
|
|
11
12
|
.field('CB_SCOPE').text().required().end
|
|
12
13
|
.field('CB_CREATE_INDICES').boolean().def(false).end
|
|
13
|
-
.
|
|
14
|
+
.end;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CbLine } from "./index.types";
|
|
2
2
|
export declare const cbLine: () => CbLine;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// ~~console.log(__filename);
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.cbLine = void 0;
|
|
5
|
+
const common_1 = require("@leyyo/common");
|
|
5
6
|
class CbLineImpl {
|
|
6
7
|
constructor() {
|
|
7
8
|
this._lines = [];
|
|
@@ -62,6 +63,34 @@ class CbLineImpl {
|
|
|
62
63
|
this._lines[index] = { mark, content: line };
|
|
63
64
|
return true;
|
|
64
65
|
}
|
|
66
|
+
both(flag, yes, no) {
|
|
67
|
+
common_1.$assert.func(yes, () => {
|
|
68
|
+
return { message: 'Invalid yes function', type: typeof yes, method: 'both' };
|
|
69
|
+
});
|
|
70
|
+
common_1.$assert.func(no, () => {
|
|
71
|
+
return { message: 'Invalid no function', type: typeof yes, method: 'both' };
|
|
72
|
+
});
|
|
73
|
+
flag ? yes() : no();
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
ifYes(flag, yes) {
|
|
77
|
+
common_1.$assert.func(yes, () => {
|
|
78
|
+
return { message: 'Invalid yes function', type: typeof yes, method: 'ifYes' };
|
|
79
|
+
});
|
|
80
|
+
if (flag) {
|
|
81
|
+
yes();
|
|
82
|
+
}
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
ifNo(flag, no) {
|
|
86
|
+
common_1.$assert.func(no, () => {
|
|
87
|
+
return { message: 'Invalid no function', type: typeof no, method: 'ifNo' };
|
|
88
|
+
});
|
|
89
|
+
if (!flag) {
|
|
90
|
+
no();
|
|
91
|
+
}
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
65
94
|
/** @inheritDoc */
|
|
66
95
|
clear() {
|
|
67
96
|
this._lines.splice(0, this._lines.length);
|
|
@@ -39,8 +39,11 @@ export interface CbLine {
|
|
|
39
39
|
* Replace marked line
|
|
40
40
|
*/
|
|
41
41
|
replace(mark: string, line: string): boolean;
|
|
42
|
+
both(flag: boolean, yes: CbLineConditionalLambda, no: CbLineConditionalLambda): CbLine;
|
|
43
|
+
ifYes(flag: boolean, yes: CbLineConditionalLambda): CbLine;
|
|
44
|
+
ifNo(flag: boolean, no: CbLineConditionalLambda): CbLine;
|
|
42
45
|
/**
|
|
43
|
-
* Builds
|
|
46
|
+
* Builds a string from lines
|
|
44
47
|
*/
|
|
45
48
|
end(): string;
|
|
46
49
|
/**
|
|
@@ -56,3 +59,4 @@ export interface CbLine {
|
|
|
56
59
|
*/
|
|
57
60
|
toString(): string;
|
|
58
61
|
}
|
|
62
|
+
export type CbLineConditionalLambda = () => void;
|
package/dist/repo/cb.repo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CbAdapterService, type CbEntity, type
|
|
2
|
-
import { Bucket, Cluster, Collection,
|
|
1
|
+
import { CbAdapterService, type CbEntity, type CbExecOpt } from "../adapter";
|
|
2
|
+
import { Bucket, Cluster, Collection, Scope } from "couchbase";
|
|
3
3
|
import type { CbRepoDef, CbRepoLike } from "./index.types";
|
|
4
4
|
export declare abstract class CbRepo<E extends CbEntity, ID> implements CbRepoLike<E, ID> {
|
|
5
5
|
protected colName: string;
|
|
@@ -19,7 +19,6 @@ export declare abstract class CbRepo<E extends CbEntity, ID> implements CbRepoLi
|
|
|
19
19
|
/** @inheritDoc */
|
|
20
20
|
readonly collection: Collection;
|
|
21
21
|
protected constructor(colName: string, cb: CbAdapterService, _scopeName?: string, _bucketName?: string);
|
|
22
|
-
protected _pushIgnoredError<O extends CbExecMutationOpt>(opt: O, err: CbError): O;
|
|
23
22
|
/**
|
|
24
23
|
* Fetch urn from doc as doc._urn
|
|
25
24
|
* */
|
|
@@ -43,53 +42,31 @@ export declare abstract class CbRepo<E extends CbEntity, ID> implements CbRepoLi
|
|
|
43
42
|
/** @inheritDoc */
|
|
44
43
|
onModuleInit(): Promise<void>;
|
|
45
44
|
/** @inheritDoc */
|
|
46
|
-
|
|
45
|
+
urnById(id: string, p1?: string | CbExecOpt): Promise<string | undefined>;
|
|
47
46
|
/** @inheritDoc */
|
|
48
|
-
|
|
47
|
+
existsByUrn(urn: string, p1?: string | CbExecOpt): Promise<boolean>;
|
|
49
48
|
/** @inheritDoc */
|
|
50
|
-
|
|
49
|
+
existsById(id: string, p1?: string | CbExecOpt): Promise<boolean>;
|
|
51
50
|
/** @inheritDoc */
|
|
52
|
-
|
|
51
|
+
getByUrn(urn: string, p1?: string | CbExecOpt): Promise<E | undefined>;
|
|
53
52
|
/** @inheritDoc */
|
|
54
|
-
|
|
53
|
+
getById(id: string, p1?: string | CbExecOpt): Promise<E | undefined>;
|
|
55
54
|
/** @inheritDoc */
|
|
56
|
-
|
|
55
|
+
listByUrn(urnList: string[], p1?: string | CbExecOpt): Promise<Array<E>>;
|
|
57
56
|
/** @inheritDoc */
|
|
58
|
-
|
|
57
|
+
listById(ids: string[], p1?: string | CbExecOpt): Promise<Array<E>>;
|
|
59
58
|
/** @inheritDoc */
|
|
60
|
-
|
|
59
|
+
removeByUrn(urn: string, p1?: string | CbExecOpt): Promise<string>;
|
|
61
60
|
/** @inheritDoc */
|
|
62
|
-
|
|
61
|
+
removeById(id: string, p1?: string | CbExecOpt): Promise<string>;
|
|
63
62
|
/** @inheritDoc */
|
|
64
|
-
|
|
63
|
+
insert(doc: E, p1?: string | CbExecOpt): Promise<string>;
|
|
65
64
|
/** @inheritDoc */
|
|
66
|
-
|
|
65
|
+
replace(doc: E, p1?: string | CbExecOpt): Promise<string>;
|
|
67
66
|
/** @inheritDoc */
|
|
68
|
-
|
|
67
|
+
upsert(doc: E, p1?: string | CbExecOpt): Promise<string>;
|
|
69
68
|
/** @inheritDoc */
|
|
70
|
-
|
|
69
|
+
update(doc: Partial<E>, p1?: string | CbExecOpt): Promise<unknown>;
|
|
71
70
|
/** @inheritDoc */
|
|
72
|
-
|
|
73
|
-
/** @inheritDoc */
|
|
74
|
-
removeByUrn(urn: string, opt?: CbExecOpt): Promise<string>;
|
|
75
|
-
/** @inheritDoc */
|
|
76
|
-
removeByUrnExtended(urn: string, query: QueryOptions, opt?: CbExecOpt): Promise<string>;
|
|
77
|
-
/** @inheritDoc */
|
|
78
|
-
removeById(id: string, opt?: CbExecOpt): Promise<string>;
|
|
79
|
-
/** @inheritDoc */
|
|
80
|
-
removeByIdExtended(id: string, query: QueryOptions, opt?: CbExecOpt): Promise<string>;
|
|
81
|
-
/** @inheritDoc */
|
|
82
|
-
insert(doc: E, opt?: CbExecMutationOpt): Promise<string>;
|
|
83
|
-
/** @inheritDoc */
|
|
84
|
-
replace(doc: E, opt?: CbExecMutationOpt): Promise<string>;
|
|
85
|
-
/** @inheritDoc */
|
|
86
|
-
upsert(doc: E, opt?: CbExecMutationOpt): Promise<string>;
|
|
87
|
-
/** @inheritDoc */
|
|
88
|
-
update(doc: Partial<E>, opt?: CbExecOpt): Promise<unknown>;
|
|
89
|
-
/** @inheritDoc */
|
|
90
|
-
updateExtended(doc: Partial<E>, query: QueryOptions, opt?: CbExecOpt): Promise<unknown>;
|
|
91
|
-
/** @inheritDoc */
|
|
92
|
-
trash(doc: E, opt?: CbExecTrashOpt): Promise<unknown>;
|
|
93
|
-
/** @inheritDoc */
|
|
94
|
-
trashExtended(doc: E, query: QueryOptions, opt?: CbExecTrashOpt): Promise<unknown>;
|
|
71
|
+
trash(doc: E, p1?: string | CbExecOpt): Promise<unknown>;
|
|
95
72
|
}
|
package/dist/repo/cb.repo.js
CHANGED
|
@@ -31,19 +31,6 @@ class CbRepo {
|
|
|
31
31
|
F_TRASH_ID = this.cb.f('_trashId');
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
// noinspection JSUnusedLocalSymbols
|
|
35
|
-
_pushIgnoredError(opt, err) {
|
|
36
|
-
if (!opt) {
|
|
37
|
-
opt = { ignoredErrors: [err] };
|
|
38
|
-
}
|
|
39
|
-
else if (!Array.isArray(opt.ignoredErrors)) {
|
|
40
|
-
opt.ignoredErrors = [err];
|
|
41
|
-
}
|
|
42
|
-
else if (!opt.ignoredErrors.includes(err)) {
|
|
43
|
-
opt.ignoredErrors.push(err);
|
|
44
|
-
}
|
|
45
|
-
return opt;
|
|
46
|
-
}
|
|
47
34
|
/**
|
|
48
35
|
* Fetch urn from doc as doc._urn
|
|
49
36
|
* */
|
|
@@ -128,9 +115,10 @@ class CbRepo {
|
|
|
128
115
|
});
|
|
129
116
|
}
|
|
130
117
|
/** @inheritDoc */
|
|
131
|
-
|
|
118
|
+
urnById(id, p1) {
|
|
132
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
120
|
var _a;
|
|
121
|
+
const opt = this.cb.buildOpt(p1, 'urnById');
|
|
134
122
|
const lines = (0, line_1.cbLine)();
|
|
135
123
|
lines
|
|
136
124
|
.add(`SELECT meta().id as ${F_URN}`)
|
|
@@ -138,25 +126,14 @@ class CbRepo {
|
|
|
138
126
|
.add(`WHERE (a.${F_ID} = ${this.cb.s(id)})`)
|
|
139
127
|
.add(`AND (a.${F_TRASH_ID} is missing)`)
|
|
140
128
|
.add('LIMIT 1');
|
|
141
|
-
return (_a = (yield this.cb.
|
|
129
|
+
return (_a = (yield this.cb.one(this, lines.end(), opt)).row) === null || _a === void 0 ? void 0 : _a._urn;
|
|
142
130
|
});
|
|
143
131
|
}
|
|
144
132
|
/** @inheritDoc */
|
|
145
|
-
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
return this.urnByIdExtended(id, undefined, opt);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
/** @inheritDoc */
|
|
151
|
-
existsByUrn(urn, opt) {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
return this.existsByUrnExtended(urn, undefined, opt);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
/** @inheritDoc */
|
|
157
|
-
existsByUrnExtended(urn, query, opt) {
|
|
133
|
+
existsByUrn(urn, p1) {
|
|
158
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
135
|
var _a;
|
|
136
|
+
const opt = this.cb.buildOpt(p1, 'existsByUrn');
|
|
160
137
|
const lines = (0, line_1.cbLine)();
|
|
161
138
|
lines
|
|
162
139
|
.add(`SELECT meta().id as ${F_URN}`)
|
|
@@ -164,30 +141,20 @@ class CbRepo {
|
|
|
164
141
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
165
142
|
.add(`USE KEYS ${this.cb.s(urn)}`)
|
|
166
143
|
.add('LIMIT 1');
|
|
167
|
-
return ((_a = (yield this.cb.
|
|
144
|
+
return ((_a = (yield this.cb.one(this, lines.end(), opt)).row) === null || _a === void 0 ? void 0 : _a._urn) !== undefined;
|
|
168
145
|
});
|
|
169
146
|
}
|
|
170
147
|
/** @inheritDoc */
|
|
171
|
-
existsById(id,
|
|
148
|
+
existsById(id, p1) {
|
|
172
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
|
|
150
|
+
const opt = this.cb.buildOpt(p1, 'existsById');
|
|
151
|
+
return (yield this.urnById(id, opt)) !== undefined;
|
|
174
152
|
});
|
|
175
153
|
}
|
|
176
154
|
/** @inheritDoc */
|
|
177
|
-
|
|
178
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
return (yield this.urnByIdExtended(id, query, opt)) !== undefined;
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
/** @inheritDoc */
|
|
183
|
-
getByUrn(urn, opt) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
return this.getByUrnExtended(urn, undefined, opt);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
/** @inheritDoc */
|
|
189
|
-
getByUrnExtended(urn, query, opt) {
|
|
155
|
+
getByUrn(urn, p1) {
|
|
190
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const opt = this.cb.buildOpt(p1, 'getByUrn');
|
|
191
158
|
const lines = (0, line_1.cbLine)();
|
|
192
159
|
lines
|
|
193
160
|
.add(`SELECT a.*`)
|
|
@@ -195,18 +162,13 @@ class CbRepo {
|
|
|
195
162
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
196
163
|
.add(`USE KEYS ${this.cb.s(urn)}`)
|
|
197
164
|
.add('LIMIT 1');
|
|
198
|
-
return this.cb.
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/** @inheritDoc */
|
|
202
|
-
getById(id, opt) {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
return this.getByIdExtended(id, undefined, opt);
|
|
165
|
+
return (yield this.cb.one(this, lines.end(), opt)).row;
|
|
205
166
|
});
|
|
206
167
|
}
|
|
207
168
|
/** @inheritDoc */
|
|
208
|
-
|
|
169
|
+
getById(id, p1) {
|
|
209
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const opt = this.cb.buildOpt(p1, 'getById');
|
|
210
172
|
const lines = (0, line_1.cbLine)();
|
|
211
173
|
lines
|
|
212
174
|
.add(`SELECT a.*`)
|
|
@@ -214,18 +176,13 @@ class CbRepo {
|
|
|
214
176
|
.add(`WHERE (a.${F_ID} = ${this.cb.s(id)})`)
|
|
215
177
|
.add(`AND (a.${F_TRASH_ID} is missing)`)
|
|
216
178
|
.add('LIMIT 1');
|
|
217
|
-
return
|
|
179
|
+
return (yield this.cb.one(this, lines.end(), opt)).row;
|
|
218
180
|
});
|
|
219
181
|
}
|
|
220
182
|
/** @inheritDoc */
|
|
221
|
-
listByUrn(urnList,
|
|
222
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
return this.listByUrnExtended(urnList, undefined, opt);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
/** @inheritDoc */
|
|
227
|
-
listByUrnExtended(urnList, query, opt) {
|
|
183
|
+
listByUrn(urnList, p1) {
|
|
228
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const opt = this.cb.buildOpt(p1, 'listByUrn');
|
|
229
186
|
urnList = this._checkKeys(urnList);
|
|
230
187
|
if (urnList.length < 1) {
|
|
231
188
|
return [];
|
|
@@ -236,18 +193,13 @@ class CbRepo {
|
|
|
236
193
|
.add(`FROM ${this.fullPath} a`)
|
|
237
194
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
238
195
|
.add(`USE KEYS [${urnList.map(urn => this.cb.s(urn)).join(',')}]`);
|
|
239
|
-
return this.cb.
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
/** @inheritDoc */
|
|
243
|
-
listById(ids, opt) {
|
|
244
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
return this.listByIdExtended(ids, undefined, opt);
|
|
196
|
+
return (yield this.cb.more(this, lines.end(), opt)).rows;
|
|
246
197
|
});
|
|
247
198
|
}
|
|
248
199
|
/** @inheritDoc */
|
|
249
|
-
|
|
200
|
+
listById(ids, p1) {
|
|
250
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
const opt = this.cb.buildOpt(p1, 'listById');
|
|
251
203
|
ids = this._checkKeys(ids);
|
|
252
204
|
if (ids.length < 1) {
|
|
253
205
|
return [];
|
|
@@ -258,19 +210,14 @@ class CbRepo {
|
|
|
258
210
|
.add(`FROM ${this.fullPath} a`)
|
|
259
211
|
.add(`WHERE (a.${F_ID} IN [${ids.map(id => this.cb.s(id)).join(',')}])`)
|
|
260
212
|
.add(`AND (a.${F_TRASH_ID} is missing)`);
|
|
261
|
-
return this.cb.
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/** @inheritDoc */
|
|
265
|
-
removeByUrn(urn, opt) {
|
|
266
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
-
return this.removeByUrnExtended(urn, undefined, opt);
|
|
213
|
+
return (yield this.cb.more(this, lines.end(), opt)).rows;
|
|
268
214
|
});
|
|
269
215
|
}
|
|
270
216
|
/** @inheritDoc */
|
|
271
|
-
|
|
217
|
+
removeByUrn(urn, p1) {
|
|
272
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
219
|
var _a;
|
|
220
|
+
const opt = this.cb.buildOpt(p1, 'removeByUrn');
|
|
274
221
|
const lines = (0, line_1.cbLine)();
|
|
275
222
|
lines
|
|
276
223
|
.add(`DELETE
|
|
@@ -278,87 +225,72 @@ class CbRepo {
|
|
|
278
225
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
279
226
|
.add(`USE KEYS ${this.cb.s(urn)}`)
|
|
280
227
|
.add(`RETURNING a.${F_ID}`);
|
|
281
|
-
return (_a = (yield this.cb.
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
/** @inheritDoc */
|
|
285
|
-
removeById(id, opt) {
|
|
286
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
287
|
-
return this.removeByIdExtended(id, undefined, opt);
|
|
228
|
+
return (_a = (yield this.cb.one(this, lines.end(), opt)).row) === null || _a === void 0 ? void 0 : _a.id;
|
|
288
229
|
});
|
|
289
230
|
}
|
|
290
231
|
/** @inheritDoc */
|
|
291
|
-
|
|
232
|
+
removeById(id, p1) {
|
|
292
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
293
234
|
var _a;
|
|
235
|
+
const opt = this.cb.buildOpt(p1, 'removeById');
|
|
294
236
|
const lines = (0, line_1.cbLine)();
|
|
295
237
|
lines
|
|
296
238
|
.add(`DELETE FROM ${this.fullPath} a`)
|
|
297
239
|
.add(`WHERE (a.${F_ID} = ${this.cb.s(id)})`)
|
|
298
240
|
.add(`AND (a.${F_TRASH_ID} is missing)`)
|
|
299
241
|
.add(`RETURNING meta().id ${F_URN}`);
|
|
300
|
-
return (_a = (yield this.cb.
|
|
242
|
+
return (_a = (yield this.cb.one(this, lines.end(), opt)).row) === null || _a === void 0 ? void 0 : _a._urn;
|
|
301
243
|
});
|
|
302
244
|
}
|
|
303
245
|
/** @inheritDoc */
|
|
304
|
-
insert(doc,
|
|
246
|
+
insert(doc, p1) {
|
|
305
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
const opt = this.cb.buildOpt(p1, 'insert');
|
|
306
249
|
const urn = this._urnFromDoc(doc, 'insert');
|
|
307
250
|
doc.createdAt = new Date().toISOString();
|
|
308
251
|
doc.updatedAt = new Date().toISOString();
|
|
309
|
-
const result = yield this.cb.
|
|
252
|
+
const result = yield this.cb.exec(this.collection.insert(urn, doc), opt);
|
|
310
253
|
return (result === null || result === void 0 ? void 0 : result.token) ? result.token.toString() : 'inserted';
|
|
311
254
|
});
|
|
312
255
|
}
|
|
313
256
|
/** @inheritDoc */
|
|
314
|
-
replace(doc,
|
|
257
|
+
replace(doc, p1) {
|
|
315
258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
const opt = this.cb.buildOpt(p1, 'replace');
|
|
316
260
|
const urn = this._urnFromDoc(doc, 'replace');
|
|
317
261
|
doc.updatedAt = new Date().toISOString();
|
|
318
|
-
const result = yield this.cb.
|
|
262
|
+
const result = yield this.cb.exec(this.collection.replace(urn, doc), opt);
|
|
319
263
|
return (result === null || result === void 0 ? void 0 : result.token) ? result.token.toString() : 'inserted';
|
|
320
264
|
});
|
|
321
265
|
}
|
|
322
266
|
/** @inheritDoc */
|
|
323
|
-
upsert(doc,
|
|
267
|
+
upsert(doc, p1) {
|
|
324
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
+
const opt = this.cb.buildOpt(p1, 'upsert');
|
|
325
270
|
const urn = this._urnFromDoc(doc, 'upsert');
|
|
326
271
|
doc.updatedAt = new Date().toISOString();
|
|
327
|
-
const result = yield this.cb.
|
|
272
|
+
const result = yield this.cb.exec(this.collection.upsert(urn, doc), opt);
|
|
328
273
|
return (result === null || result === void 0 ? void 0 : result.token) ? result.token.toString() : 'modified';
|
|
329
274
|
});
|
|
330
275
|
}
|
|
331
276
|
/** @inheritDoc */
|
|
332
|
-
update(doc,
|
|
333
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
334
|
-
return this.updateExtended(doc, undefined, opt);
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
/** @inheritDoc */
|
|
338
|
-
updateExtended(doc, query, opt) {
|
|
277
|
+
update(doc, p1) {
|
|
339
278
|
return __awaiter(this, void 0, void 0, function* () {
|
|
340
279
|
var _a;
|
|
280
|
+
const opt = this.cb.buildOpt(p1, 'update');
|
|
341
281
|
const urn = this._urnFromDoc(doc, 'update');
|
|
342
282
|
doc.updatedAt = new Date().toISOString();
|
|
343
283
|
doc.updatedAt = new Date().toISOString();
|
|
344
284
|
const sql = this._updateSql(urn, doc);
|
|
345
|
-
return (_a = (yield this.cb.
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
/** @inheritDoc */
|
|
349
|
-
trash(doc, opt) {
|
|
350
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
-
return this.trashExtended(doc, undefined, opt);
|
|
285
|
+
return (_a = (yield this.cb.one(this, sql, opt)).row) === null || _a === void 0 ? void 0 : _a._urn;
|
|
352
286
|
});
|
|
353
287
|
}
|
|
354
288
|
/** @inheritDoc */
|
|
355
|
-
|
|
289
|
+
trash(doc, p1) {
|
|
356
290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
const opt = this.cb.buildOpt(p1, 'trash');
|
|
357
292
|
const urn = this._urnFromDoc(doc, 'trash');
|
|
358
|
-
if (
|
|
359
|
-
opt = { trashId: (0, node_crypto_1.randomUUID)() };
|
|
360
|
-
}
|
|
361
|
-
else if (!opt.trashId) {
|
|
293
|
+
if (opt.trashId === undefined) {
|
|
362
294
|
opt.trashId = (0, node_crypto_1.randomUUID)();
|
|
363
295
|
}
|
|
364
296
|
const lines = (0, line_1.cbLine)();
|
|
@@ -367,7 +299,7 @@ class CbRepo {
|
|
|
367
299
|
.add(`SET a.${F_TRASH_ID} = ${this.cb.s(opt.trashId)}`)
|
|
368
300
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
369
301
|
.add(`USE KEYS ${this.cb.s(urn)}`);
|
|
370
|
-
yield this.cb.
|
|
302
|
+
yield this.cb.one(this, lines.end(), opt);
|
|
371
303
|
return opt.trashId;
|
|
372
304
|
});
|
|
373
305
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Bucket, Cluster, Collection,
|
|
2
|
-
import type { CbEntity,
|
|
1
|
+
import type { Bucket, Cluster, Collection, Scope } from "couchbase";
|
|
2
|
+
import type { CbEntity, CbExecOpt } from "../adapter";
|
|
3
3
|
export interface CbRepoLike<E extends CbEntity, ID> {
|
|
4
4
|
/**
|
|
5
5
|
* Readable Bucket/Scope/Collection path
|
|
@@ -37,103 +37,73 @@ export interface CbRepoLike<E extends CbEntity, ID> {
|
|
|
37
37
|
/**
|
|
38
38
|
* Get urn by id
|
|
39
39
|
* */
|
|
40
|
+
urnById(id: string, name?: string): Promise<string | undefined>;
|
|
40
41
|
urnById(id: string, opt?: CbExecOpt): Promise<string | undefined>;
|
|
41
|
-
/**
|
|
42
|
-
* Get urn by id with CB configuration
|
|
43
|
-
* */
|
|
44
|
-
urnByIdExtended(id: string, query: QueryOptions, opt?: CbExecOpt): Promise<string | undefined>;
|
|
45
42
|
/**
|
|
46
43
|
* Doc exists by urn?
|
|
47
44
|
* */
|
|
45
|
+
existsByUrn(urn: string, name?: string): Promise<boolean>;
|
|
48
46
|
existsByUrn(urn: string, opt?: CbExecOpt): Promise<boolean>;
|
|
49
|
-
/**
|
|
50
|
-
* Doc exists by urn? with CB configuration
|
|
51
|
-
* */
|
|
52
|
-
existsByUrnExtended(urn: string, query: QueryOptions, opt?: CbExecOpt): Promise<boolean>;
|
|
53
47
|
/**
|
|
54
48
|
* Doc exists by id?
|
|
55
49
|
* */
|
|
50
|
+
existsById(id: string, name?: string): Promise<boolean>;
|
|
56
51
|
existsById(id: string, opt?: CbExecOpt): Promise<boolean>;
|
|
57
|
-
/**
|
|
58
|
-
* Doc exists by id? with CB configuration
|
|
59
|
-
* */
|
|
60
|
-
existsByIdExtended(id: string, query: QueryOptions, opt?: CbExecOpt): Promise<boolean>;
|
|
61
52
|
/**
|
|
62
53
|
* Get doc by urn
|
|
63
54
|
* */
|
|
55
|
+
getByUrn(urn: string, name?: string): Promise<E | undefined>;
|
|
64
56
|
getByUrn(urn: string, opt?: CbExecOpt): Promise<E | undefined>;
|
|
65
|
-
/**
|
|
66
|
-
* Get doc by urn with CB configuration
|
|
67
|
-
* */
|
|
68
|
-
getByUrnExtended(urn: string, query: QueryOptions, opt?: CbExecOpt): Promise<E | undefined>;
|
|
69
57
|
/**
|
|
70
58
|
* Get doc by id
|
|
71
59
|
* */
|
|
60
|
+
getById(id: string, name?: string): Promise<E | undefined>;
|
|
72
61
|
getById(id: string, opt?: CbExecOpt): Promise<E | undefined>;
|
|
73
|
-
/**
|
|
74
|
-
* Get doc by id with CB configuration
|
|
75
|
-
* */
|
|
76
|
-
getByIdExtended(id: string, query: QueryOptions, opt?: CbExecOpt): Promise<E | undefined>;
|
|
77
62
|
/**
|
|
78
63
|
* Get doc by urn
|
|
79
64
|
* */
|
|
65
|
+
listByUrn(urnList: string[], name?: string): Promise<Array<E>>;
|
|
80
66
|
listByUrn(urnList: string[], opt?: CbExecOpt): Promise<Array<E>>;
|
|
81
|
-
/**
|
|
82
|
-
* Get doc by urn with CB configuration
|
|
83
|
-
* */
|
|
84
|
-
listByUrnExtended(urnList: string[], query: QueryOptions, opt?: CbExecOpt): Promise<Array<E>>;
|
|
85
67
|
/**
|
|
86
68
|
* Get doc by id
|
|
87
69
|
* */
|
|
70
|
+
listById(ids: string[], name?: string): Promise<Array<E>>;
|
|
88
71
|
listById(ids: string[], opt?: CbExecOpt): Promise<Array<E>>;
|
|
89
|
-
/**
|
|
90
|
-
* Get doc by id with CB configuration
|
|
91
|
-
* */
|
|
92
|
-
listByIdExtended(ids: string[], query: QueryOptions, opt?: CbExecOpt): Promise<Array<E>>;
|
|
93
72
|
/**
|
|
94
73
|
* Remove doc by urn
|
|
95
74
|
* */
|
|
75
|
+
removeByUrn(urn: string, name?: string): Promise<string>;
|
|
96
76
|
removeByUrn(urn: string, opt?: CbExecOpt): Promise<string>;
|
|
97
|
-
/**
|
|
98
|
-
* Remove doc by urn with CB configuration
|
|
99
|
-
* */
|
|
100
|
-
removeByUrnExtended(urn: string, query: QueryOptions, opt?: CbExecOpt): Promise<string>;
|
|
101
77
|
/**
|
|
102
78
|
* Remove doc by urn
|
|
103
79
|
* */
|
|
80
|
+
removeById(id: string, name?: string): Promise<string>;
|
|
104
81
|
removeById(id: string, opt?: CbExecOpt): Promise<string>;
|
|
105
|
-
/**
|
|
106
|
-
* Remove doc by urn with CB configuration
|
|
107
|
-
* */
|
|
108
|
-
removeByIdExtended(id: string, query: QueryOptions, opt?: CbExecOpt): Promise<string>;
|
|
109
82
|
/**
|
|
110
83
|
* Create doc by entity
|
|
111
84
|
* */
|
|
112
|
-
insert(doc: E,
|
|
85
|
+
insert(doc: E, name?: string): Promise<string>;
|
|
86
|
+
insert(doc: E, opt?: CbExecOpt): Promise<string>;
|
|
113
87
|
/**
|
|
114
88
|
* Replace doc by entity
|
|
115
89
|
* */
|
|
116
|
-
replace(doc: E,
|
|
90
|
+
replace(doc: E, name?: string): Promise<string>;
|
|
91
|
+
replace(doc: E, opt?: CbExecOpt): Promise<string>;
|
|
117
92
|
/**
|
|
118
93
|
* Upsert doc by entity (insert vs update)
|
|
119
94
|
* */
|
|
120
|
-
upsert(doc: E,
|
|
95
|
+
upsert(doc: E, name?: string): Promise<string>;
|
|
96
|
+
upsert(doc: E, opt?: CbExecOpt): Promise<string>;
|
|
121
97
|
/**
|
|
122
98
|
* Update doc
|
|
123
99
|
* */
|
|
100
|
+
update(doc: Partial<E>, name?: string): Promise<unknown>;
|
|
124
101
|
update(doc: Partial<E>, opt?: CbExecOpt): Promise<unknown>;
|
|
125
|
-
/**
|
|
126
|
-
* Update doc with CB configuration
|
|
127
|
-
* */
|
|
128
|
-
updateExtended(doc: Partial<E>, query: QueryOptions, opt?: CbExecOpt): Promise<unknown>;
|
|
129
102
|
/**
|
|
130
103
|
* Trash doc by entity
|
|
131
104
|
* */
|
|
132
|
-
trash(doc: E,
|
|
133
|
-
|
|
134
|
-
* Trash doc by entity with CB configuration
|
|
135
|
-
* */
|
|
136
|
-
trashExtended(doc: E, query: QueryOptions, opt?: CbExecTrashOpt): Promise<unknown>;
|
|
105
|
+
trash(doc: E, name?: string): Promise<unknown>;
|
|
106
|
+
trash(doc: E, opt?: CbExecOpt): Promise<unknown>;
|
|
137
107
|
}
|
|
138
108
|
export interface CbOnlyUrnRec {
|
|
139
109
|
_urn: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-couchbase-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Couchbase common component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Couchbase"
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@leyyo/common": "^1.0.13",
|
|
70
|
-
"@leyyo/env": "^1.0.
|
|
70
|
+
"@leyyo/env": "^1.0.13",
|
|
71
71
|
"@nestjs/common": "^11.0.20",
|
|
72
|
-
"@samet-it/be-base-common": "^1.0.
|
|
72
|
+
"@samet-it/be-base-common": "^1.0.9",
|
|
73
73
|
"couchbase": "^4.6.0"
|
|
74
74
|
}
|
|
75
75
|
}
|