@samet-it/be-couchbase-common 1.0.10 → 1.0.11
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/repo/cb.repo.d.ts +2 -1
- package/dist/repo/cb.repo.js +21 -5
- package/package.json +1 -1
package/dist/repo/cb.repo.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare abstract class CbRepo<E extends CbEntity, ID> implements CbRepoLi
|
|
|
8
8
|
private _scopeName?;
|
|
9
9
|
private _bucketName?;
|
|
10
10
|
private _tryCount;
|
|
11
|
+
private _pkIndexed;
|
|
11
12
|
protected logger: Logger;
|
|
12
13
|
/** @inheritDoc */
|
|
13
14
|
readonly fullPath: string;
|
|
@@ -45,7 +46,7 @@ export declare abstract class CbRepo<E extends CbEntity, ID> implements CbRepoLi
|
|
|
45
46
|
/**
|
|
46
47
|
* Execute the creation of indexes with keys
|
|
47
48
|
* */
|
|
48
|
-
protected _createMoreIndices(...keys: Array<keyof
|
|
49
|
+
protected _createMoreIndices(...keys: Array<keyof E>): Promise<void>;
|
|
49
50
|
/**
|
|
50
51
|
* Execute the creation of primary key
|
|
51
52
|
* */
|
package/dist/repo/cb.repo.js
CHANGED
|
@@ -127,9 +127,22 @@ class CbRepo {
|
|
|
127
127
|
* */
|
|
128
128
|
_createMoreIndices(...keys) {
|
|
129
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const
|
|
131
|
-
promises
|
|
132
|
-
|
|
130
|
+
const already = [];
|
|
131
|
+
const promises = keys
|
|
132
|
+
.filter(k => {
|
|
133
|
+
if (already.includes(k)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
already.push(k);
|
|
137
|
+
return true;
|
|
138
|
+
})
|
|
139
|
+
.map(k => this._createIndex(k));
|
|
140
|
+
if (!this._pkIndexed) {
|
|
141
|
+
promises.push(this._createPk());
|
|
142
|
+
}
|
|
143
|
+
if (promises.length > 0) {
|
|
144
|
+
yield Promise.all(promises);
|
|
145
|
+
}
|
|
133
146
|
});
|
|
134
147
|
}
|
|
135
148
|
/**
|
|
@@ -137,8 +150,11 @@ class CbRepo {
|
|
|
137
150
|
* */
|
|
138
151
|
_createPk() {
|
|
139
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
if (!this._pkIndexed) {
|
|
154
|
+
const sql = `CREATE PRIMARY INDEX \`pk\` ON ${this.fullPath}`;
|
|
155
|
+
yield this.cb.one(this.def, sql, { name: `${this.path}.pk`, ignoredErrors: [couchbase_1.IndexExistsError] });
|
|
156
|
+
this._pkIndexed = true;
|
|
157
|
+
}
|
|
142
158
|
});
|
|
143
159
|
}
|
|
144
160
|
/** @inheritDoc */
|