@samet-it/be-couchbase-common 1.1.1 → 1.1.3
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.
|
@@ -11,6 +11,9 @@ export declare abstract class CbConnection extends DbConnection<CbRepoDef, Query
|
|
|
11
11
|
/** {@inheritDoc} */
|
|
12
12
|
protected _props: CbConnProps;
|
|
13
13
|
protected constructor(opt?: CbConnOpt);
|
|
14
|
+
/**
|
|
15
|
+
* Read configuration by variant
|
|
16
|
+
* */
|
|
14
17
|
protected _readEnv(): void;
|
|
15
18
|
/** {@inheritDoc} */
|
|
16
19
|
get props(): Readonly<CbConnProps>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// ~~console.log(__filename);
|
|
3
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
3
|
if (k2 === undefined) k2 = k;
|
|
5
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -61,6 +60,9 @@ class CbConnection extends be_db_common_1.DbConnection {
|
|
|
61
60
|
this._readEnv();
|
|
62
61
|
}
|
|
63
62
|
// region protected-method
|
|
63
|
+
/**
|
|
64
|
+
* Read configuration by variant
|
|
65
|
+
* */
|
|
64
66
|
_readEnv() {
|
|
65
67
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
66
68
|
const { _props: props } = this;
|
package/dist/repo/cb.repo.d.ts
CHANGED
|
@@ -8,22 +8,36 @@ import type { QueryRegular } from "@leyyo/query";
|
|
|
8
8
|
/**
|
|
9
9
|
* Couchbase repository abstract class
|
|
10
10
|
* */
|
|
11
|
-
export declare class CbRepo<ID extends KeyValue, ENTITY extends Entity<ID>, URN extends UrnDocLike, KEYS extends string = string, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = View<ID>, PORTION extends Portion<ID> = Portion<ID>> extends DbRepo<CbConnectionLike, CbExecOpt, ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> implements CbRepoLike<ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> {
|
|
11
|
+
export declare abstract class CbRepo<ID extends KeyValue, ENTITY extends Entity<ID>, URN extends UrnDocLike, KEYS extends string = string, DIMS extends DefDims = DefDims, PAIR extends Pair<ID> = Pair<ID>, VIEW extends View<ID> = View<ID>, PORTION extends Portion<ID> = Portion<ID>> extends DbRepo<CbConnectionLike, CbExecOpt, ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> implements CbRepoLike<ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> {
|
|
12
12
|
private static _specs;
|
|
13
13
|
/** @inheritDoc */
|
|
14
14
|
protected _props: CbRepoProps<ID, ENTITY>;
|
|
15
15
|
protected constructor(conn: CbConnectionLike, opt?: CbRepoOpt<ID, ENTITY>);
|
|
16
|
+
/**
|
|
17
|
+
* Check property name
|
|
18
|
+
*
|
|
19
|
+
* @param {string} value
|
|
20
|
+
* @return {string}
|
|
21
|
+
* */
|
|
16
22
|
protected _checkName(value: string): string;
|
|
17
23
|
/**
|
|
18
24
|
* Execute the creation of index for one field
|
|
25
|
+
*
|
|
26
|
+
* @param {string} field - field name
|
|
27
|
+
* @param {string?} name - index name
|
|
19
28
|
* */
|
|
20
29
|
protected _createIndex(field: keyof ENTITY | string, name?: string): Promise<void>;
|
|
21
30
|
/**
|
|
22
31
|
* Execute the creation of index for complex fields
|
|
32
|
+
*
|
|
33
|
+
* @param {Array<string>} fields - field names
|
|
34
|
+
* @param {string} name - index name
|
|
23
35
|
* */
|
|
24
36
|
protected _createIndex(fields: Array<keyof ENTITY | string>, name: string): Promise<void>;
|
|
25
37
|
/**
|
|
26
38
|
* Execute the creation of indexes with keys
|
|
39
|
+
*
|
|
40
|
+
* @param {...Array<string>} keys - keys of model
|
|
27
41
|
* */
|
|
28
42
|
protected _createMoreIndices(...keys: Array<keyof ENTITY>): Promise<void>;
|
|
29
43
|
/**
|
|
@@ -32,11 +46,22 @@ export declare class CbRepo<ID extends KeyValue, ENTITY extends Entity<ID>, URN
|
|
|
32
46
|
protected _createPk(): Promise<void>;
|
|
33
47
|
/** @inheritDoc */
|
|
34
48
|
protected _afterConnected(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Load & check bucket by cluster
|
|
51
|
+
* */
|
|
35
52
|
private _loadBucket;
|
|
53
|
+
/**
|
|
54
|
+
* Load & check scope by bucket
|
|
55
|
+
* */
|
|
36
56
|
private _loadScope;
|
|
57
|
+
/**
|
|
58
|
+
* Load & check collection by scope
|
|
59
|
+
* */
|
|
37
60
|
private _loadCollection;
|
|
38
61
|
/**
|
|
39
62
|
* Create indices in final repo
|
|
63
|
+
*
|
|
64
|
+
* can be @override
|
|
40
65
|
* */
|
|
41
66
|
protected $createIndices(): Promise<void>;
|
|
42
67
|
/** @inheritDoc */
|
package/dist/repo/cb.repo.js
CHANGED
|
@@ -50,6 +50,12 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
// region protected-method
|
|
53
|
+
/**
|
|
54
|
+
* Check property name
|
|
55
|
+
*
|
|
56
|
+
* @param {string} value
|
|
57
|
+
* @return {string}
|
|
58
|
+
* */
|
|
53
59
|
_checkName(value) {
|
|
54
60
|
if (typeof value === 'string') {
|
|
55
61
|
value = value.trim();
|
|
@@ -64,6 +70,9 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
* Execute the creation of index
|
|
73
|
+
*
|
|
74
|
+
* @param {OneOrMore<string>} p1 - field name or field names
|
|
75
|
+
* @param {string?} name - index name
|
|
67
76
|
* */
|
|
68
77
|
_createIndex(p1, name) {
|
|
69
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -92,6 +101,8 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
92
101
|
// noinspection JSUnusedGlobalSymbols
|
|
93
102
|
/**
|
|
94
103
|
* Execute the creation of indexes with keys
|
|
104
|
+
*
|
|
105
|
+
* @param {...Array<string>} keys - keys of model
|
|
95
106
|
* */
|
|
96
107
|
_createMoreIndices(...keys) {
|
|
97
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -139,6 +150,9 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
139
150
|
}
|
|
140
151
|
});
|
|
141
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Load & check bucket by cluster
|
|
155
|
+
* */
|
|
142
156
|
_loadBucket() {
|
|
143
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
158
|
const { _props: props } = this;
|
|
@@ -159,6 +173,9 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
159
173
|
props.bucket = ins;
|
|
160
174
|
});
|
|
161
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Load & check scope by bucket
|
|
178
|
+
* */
|
|
162
179
|
_loadScope() {
|
|
163
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
181
|
const { _props: props } = this;
|
|
@@ -179,6 +196,9 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
179
196
|
props.scope = ins;
|
|
180
197
|
});
|
|
181
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Load & check collection by scope
|
|
201
|
+
* */
|
|
182
202
|
_loadCollection() {
|
|
183
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
204
|
const { _props: props } = this;
|
|
@@ -195,6 +215,8 @@ class CbRepo extends be_db_common_1.DbRepo {
|
|
|
195
215
|
}
|
|
196
216
|
/**
|
|
197
217
|
* Create indices in final repo
|
|
218
|
+
*
|
|
219
|
+
* can be @override
|
|
198
220
|
* */
|
|
199
221
|
$createIndices() {
|
|
200
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -5,7 +5,13 @@ import type { DefDims, Entity, Pair, Portion, UrnDocLike, View } from "@samet-it
|
|
|
5
5
|
import type { ExistsOptions, GetOptions, InsertOptions, ReplaceOptions } from "couchbase";
|
|
6
6
|
import type { DbRepoProps } from "@samet-it/be-db-common";
|
|
7
7
|
import type { KeyValue } from "@leyyo/common";
|
|
8
|
+
/**
|
|
9
|
+
* General result for mutable queries to return key
|
|
10
|
+
* */
|
|
8
11
|
export interface CbResultX {
|
|
12
|
+
/**
|
|
13
|
+
* It should be `meta().id`
|
|
14
|
+
* */
|
|
9
15
|
x: string;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
@@ -110,14 +116,26 @@ export interface CbRepoProps<ID extends KeyValue, ENTITY extends Entity<ID>> ext
|
|
|
110
116
|
* Couchbase repository (collection) props part for extended usage
|
|
111
117
|
* */
|
|
112
118
|
export interface CbRepoPropsPart<S> {
|
|
119
|
+
/**
|
|
120
|
+
* Extended property to hold couchbase specs
|
|
121
|
+
* */
|
|
113
122
|
readonly $spec?: S;
|
|
114
123
|
}
|
|
115
124
|
/**
|
|
116
125
|
* Couchbase direct repository (collection) option
|
|
117
126
|
* */
|
|
118
127
|
export interface CbRepoDirectOpt<ID extends KeyValue, ENTITY extends Entity<ID>, URN extends UrnDocLike, DIMS extends DefDims = DefDims, R = unknown> extends CbRepoOpt<ID, ENTITY> {
|
|
128
|
+
/**
|
|
129
|
+
* Name of logger class
|
|
130
|
+
* */
|
|
119
131
|
name?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Overridable method to easy use
|
|
134
|
+
* */
|
|
120
135
|
toUrnTuple?: DbRepoToUrnTuple<URN>;
|
|
136
|
+
/**
|
|
137
|
+
* Overridable method to easy use
|
|
138
|
+
* */
|
|
121
139
|
toDim?: DbRepoToDim<R, ID, ENTITY, DIMS>;
|
|
122
140
|
}
|
|
123
141
|
/**
|
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.3",
|
|
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.
|
|
75
|
+
"@samet-it/be-db-common": "^1.1.1",
|
|
76
76
|
"couchbase": "^4.6.0"
|
|
77
77
|
}
|
|
78
78
|
}
|