@samet-it/be-couchbase-common 1.0.6 → 1.0.8
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.
|
@@ -165,7 +165,7 @@ let CbAdapterService = class CbAdapterService {
|
|
|
165
165
|
this.logger.warn(`${opt.name} => (${err.name})${err.message}`);
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
|
-
this.logger.
|
|
168
|
+
this.logger.debug(`${opt.name} => (${err.name})${err.message}`, JSON.stringify(err.context));
|
|
169
169
|
throw err;
|
|
170
170
|
}
|
|
171
171
|
/** {@inheritDoc} */
|
|
@@ -250,10 +250,10 @@ let CbAdapterService = class CbAdapterService {
|
|
|
250
250
|
const obj = this._cbErrors.get(name);
|
|
251
251
|
obj.count++;
|
|
252
252
|
if (obj.known) {
|
|
253
|
-
this.logger.
|
|
253
|
+
this.logger.debug(`!known[${name}] #${op} [${obj.count}]`, err);
|
|
254
254
|
}
|
|
255
255
|
else {
|
|
256
|
-
this.logger.
|
|
256
|
+
this.logger.debug(`!unknown[${name}] #${op} [${obj.count}]`, err);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
}
|
package/dist/repo/cb.repo.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { CbAdapterService, type CbEntity, type CbExecOpt } from "../adapter";
|
|
2
2
|
import { Bucket, Cluster, Collection, Scope } from "couchbase";
|
|
3
3
|
import type { CbRepoDef, CbRepoLike } from "./index.types";
|
|
4
|
+
import { Logger } from "@nestjs/common";
|
|
4
5
|
export declare abstract class CbRepo<E extends CbEntity, ID> implements CbRepoLike<E, ID> {
|
|
5
6
|
protected colName: string;
|
|
6
7
|
protected cb: CbAdapterService;
|
|
7
8
|
private _scopeName?;
|
|
8
9
|
private _bucketName?;
|
|
10
|
+
private _tryCount;
|
|
11
|
+
protected logger: Logger;
|
|
9
12
|
/** @inheritDoc */
|
|
10
13
|
readonly fullPath: string;
|
|
11
14
|
/** @inheritDoc */
|
package/dist/repo/cb.repo.js
CHANGED
|
@@ -15,6 +15,7 @@ const common_1 = require("@leyyo/common");
|
|
|
15
15
|
const config_1 = require("../config");
|
|
16
16
|
const line_1 = require("../line");
|
|
17
17
|
const node_crypto_1 = require("node:crypto");
|
|
18
|
+
const common_2 = require("@nestjs/common");
|
|
18
19
|
let F_ID;
|
|
19
20
|
let F_URN;
|
|
20
21
|
let F_TRASH_ID;
|
|
@@ -25,6 +26,8 @@ class CbRepo {
|
|
|
25
26
|
this.cb = cb;
|
|
26
27
|
this._scopeName = _scopeName;
|
|
27
28
|
this._bucketName = _bucketName;
|
|
29
|
+
this._tryCount = 0;
|
|
30
|
+
this.logger = new common_2.Logger(this.constructor.name);
|
|
28
31
|
if (!F_ID) {
|
|
29
32
|
F_ID = this.cb.f('id');
|
|
30
33
|
F_URN = this.cb.f('_urn');
|
|
@@ -103,14 +106,26 @@ class CbRepo {
|
|
|
103
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
107
|
var _a, _b;
|
|
105
108
|
const mutable = this;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
try {
|
|
110
|
+
mutable.cluster = yield this.cb.connectDb();
|
|
111
|
+
mutable.bucket = this.cluster.bucket((_a = this._bucketName) !== null && _a !== void 0 ? _a : config_1.couchbaseCommonConfig.raw.CB_BUCKET);
|
|
112
|
+
mutable.scope = this.bucket.scope((_b = this._scopeName) !== null && _b !== void 0 ? _b : config_1.couchbaseCommonConfig.raw.CB_SCOPE);
|
|
113
|
+
mutable.collection = this.scope.collection(this.colName);
|
|
114
|
+
mutable.path = `${this.bucket.name}.${this.scope.name}.${this.collection.name}`;
|
|
115
|
+
mutable.fullPath = this.cb.f(`${this.bucket.name}.${this.scope.name}.${this.collection.name}`);
|
|
116
|
+
if (config_1.couchbaseCommonConfig.raw.CB_CREATE_INDICES) {
|
|
117
|
+
yield this._createIndices();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (this._tryCount > 100) {
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
124
|
+
this._tryCount++;
|
|
125
|
+
this.logger.error(`[${this._tryCount}] ${e.name} => ${e.message}`);
|
|
126
|
+
setTimeout(() => this.onModuleInit().then().catch(e2 => {
|
|
127
|
+
throw e2;
|
|
128
|
+
}), 1000);
|
|
114
129
|
}
|
|
115
130
|
});
|
|
116
131
|
}
|