@samet-it/be-couchbase-common 1.0.16 → 1.1.1
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/README.md +10 -10
- package/dist/config/couchbase-common.config.d.ts +5 -1
- package/dist/config/couchbase-common.config.js +15 -9
- package/dist/config/index.types.d.ts +17 -13
- package/dist/connection/cb-connection.fn.d.ts +8 -0
- package/dist/connection/cb-connection.fn.js +14 -0
- package/dist/connection/cb-direct.connection.d.ts +13 -0
- package/dist/connection/cb-direct.connection.js +21 -0
- package/dist/connection/cb.connection.d.ts +35 -0
- package/dist/{adapter/cb-adapter.service.js → connection/cb.connection.js} +99 -127
- package/dist/connection/index.d.ts +4 -0
- package/dist/{adapter → connection}/index.js +3 -2
- package/dist/connection/index.types.d.ts +94 -0
- package/dist/filter/cb-filter-util.impl.js +4 -4
- package/dist/filter/index.types.d.ts +4 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -6
- package/dist/repo/cb-direct.repo.d.ts +11 -0
- package/dist/repo/cb-direct.repo.js +37 -0
- package/dist/repo/cb-schema.error.d.ts +4 -0
- package/dist/repo/cb-schema.error.js +10 -0
- package/dist/repo/cb.repo.d.ts +43 -61
- package/dist/repo/cb.repo.js +480 -269
- package/dist/repo/index.d.ts +2 -0
- package/dist/repo/index.js +2 -0
- package/dist/repo/index.types.d.ts +121 -93
- package/package.json +8 -5
- package/dist/adapter/cb-adapter.module.d.ts +0 -2
- package/dist/adapter/cb-adapter.module.js +0 -23
- package/dist/adapter/cb-adapter.service.d.ts +0 -46
- package/dist/adapter/index.d.ts +0 -3
- package/dist/adapter/index.types.d.ts +0 -135
- package/dist/assets/source.MD +0 -1
- package/dist/line/cb-line.impl.d.ts +0 -2
- package/dist/line/cb-line.impl.js +0 -119
- package/dist/line/index.d.ts +0 -2
- package/dist/line/index.js +0 -18
- package/dist/line/index.types.d.ts +0 -62
- package/dist/line/index.types.js +0 -2
- /package/dist/{adapter → connection}/index.types.js +0 -0
package/dist/repo/cb.repo.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// ~~console.log(__filename);
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,144 +11,85 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
12
|
exports.CbRepo = void 0;
|
|
14
13
|
const couchbase_1 = require("couchbase");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const common_2 = require("@nestjs/common");
|
|
20
|
-
let F_ID;
|
|
14
|
+
const be_db_common_1 = require("@samet-it/be-db-common");
|
|
15
|
+
const type_1 = require("@leyyo/type");
|
|
16
|
+
const type_2 = require("@leyyo/type");
|
|
17
|
+
const cb_schema_error_1 = require("./cb-schema.error");
|
|
21
18
|
let F_URN;
|
|
19
|
+
let F_ID;
|
|
22
20
|
let F_TRASH_ID;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
.join('_');
|
|
42
|
-
}
|
|
43
|
-
_indexName(name) {
|
|
44
|
-
if (typeof name !== 'string') {
|
|
45
|
-
return this._randomIndexName;
|
|
46
|
-
}
|
|
47
|
-
name = name.trim();
|
|
48
|
-
if (name === '') {
|
|
49
|
-
return this._randomIndexName;
|
|
21
|
+
/**
|
|
22
|
+
* Couchbase repository abstract class
|
|
23
|
+
* */
|
|
24
|
+
class CbRepo extends be_db_common_1.DbRepo {
|
|
25
|
+
// endregion protected-property
|
|
26
|
+
constructor(conn, opt) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
super(conn, opt);
|
|
29
|
+
conn.onFirstConnected(() => this._afterConnected());
|
|
30
|
+
const { _props: props } = this;
|
|
31
|
+
props.bucketName = this._checkName(props.bucketName);
|
|
32
|
+
props.scopeName = this._checkName(props.scopeName);
|
|
33
|
+
props.collectionName = this._checkName(props.collectionName);
|
|
34
|
+
props.bucketName = (_a = props.bucketName) !== null && _a !== void 0 ? _a : conn.props.bucketName;
|
|
35
|
+
props.scopeName = (_b = props.scopeName) !== null && _b !== void 0 ? _b : conn.props.scopeName;
|
|
36
|
+
props.createIndices = (_c = props.createIndices) !== null && _c !== void 0 ? _c : conn.props.createIndices;
|
|
37
|
+
if (!props.bucketName) {
|
|
38
|
+
throw new be_db_common_1.DbInvalidValueError('Bucket', typeof props.bucketName, 'CbRepo', 'constructor');
|
|
50
39
|
}
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
.join('_');
|
|
54
|
-
name = name.replace(/^_+|_+$/g, '');
|
|
55
|
-
if (name === '') {
|
|
56
|
-
return this._randomIndexName;
|
|
40
|
+
if (!props.scopeName) {
|
|
41
|
+
throw new be_db_common_1.DbInvalidValueError('Scope', typeof props.scopeName, 'CbRepo', 'constructor');
|
|
57
42
|
}
|
|
58
|
-
if (!
|
|
59
|
-
|
|
43
|
+
if (!props.collectionName) {
|
|
44
|
+
throw new be_db_common_1.DbInvalidValueError('Collection', typeof props.collectionName, 'CbRepo', 'constructor');
|
|
60
45
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Fetch urn from doc as doc._urn
|
|
68
|
-
* */
|
|
69
|
-
_urnFromDoc(doc, method) {
|
|
70
|
-
common_1.$assert.object(doc, () => {
|
|
71
|
-
return { field: 'doc', where: 'CbRepo', path: this.path, method };
|
|
72
|
-
});
|
|
73
|
-
const urn = doc._urn;
|
|
74
|
-
common_1.$assert.text(urn, () => {
|
|
75
|
-
return { field: 'urn', where: 'CbRepo', path: this.path, method };
|
|
76
|
-
});
|
|
77
|
-
return urn;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Check array keys as id list or urn list
|
|
81
|
-
* */
|
|
82
|
-
_checkKeys(keys) {
|
|
83
|
-
if (!keys || !Array.isArray(keys) || keys.length < 1) {
|
|
84
|
-
return [];
|
|
46
|
+
if (!F_URN) {
|
|
47
|
+
F_URN = props.conn.f('_urn');
|
|
48
|
+
F_ID = props.conn.f('id');
|
|
49
|
+
F_TRASH_ID = props.conn.f('_trashId');
|
|
85
50
|
}
|
|
86
|
-
return keys
|
|
87
|
-
.map(item => {
|
|
88
|
-
switch (typeof item) {
|
|
89
|
-
case 'string':
|
|
90
|
-
const str = item.trim();
|
|
91
|
-
return str ? str : undefined;
|
|
92
|
-
case 'number':
|
|
93
|
-
return item;
|
|
94
|
-
default:
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
.filter(item => item !== undefined);
|
|
99
51
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const unset = [];
|
|
107
|
-
for (const [k, v] of Object.entries(doc)) {
|
|
108
|
-
if (!['_urn', 'id'].includes(k)) {
|
|
109
|
-
if (v === undefined) {
|
|
110
|
-
unset.push(cb.f(k));
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
set.push([cb.f(k), cb.v(v)]);
|
|
114
|
-
}
|
|
52
|
+
// region protected-method
|
|
53
|
+
_checkName(value) {
|
|
54
|
+
if (typeof value === 'string') {
|
|
55
|
+
value = value.trim();
|
|
56
|
+
if (!value) {
|
|
57
|
+
value = undefined;
|
|
115
58
|
}
|
|
116
59
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.add(`UPDATE ${this.fullPath}`)
|
|
120
|
-
.add(`USE KEYS ${cb.v(urn)}`);
|
|
121
|
-
if (unset.length > 0) {
|
|
122
|
-
lines.add('UNSET ', unset.join(', '));
|
|
60
|
+
else {
|
|
61
|
+
value = undefined;
|
|
123
62
|
}
|
|
124
|
-
|
|
125
|
-
lines.add('SET ', set.join(',\n '));
|
|
126
|
-
}
|
|
127
|
-
lines.add(`RETURNING meta().id ${F_URN}`);
|
|
128
|
-
return lines.end();
|
|
63
|
+
return value;
|
|
129
64
|
}
|
|
130
65
|
/**
|
|
131
66
|
* Execute the creation of index
|
|
132
67
|
* */
|
|
133
68
|
_createIndex(p1, name) {
|
|
134
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const { conn, full, path } = this._props;
|
|
135
71
|
let sql;
|
|
136
72
|
const fields = [];
|
|
137
73
|
if (Array.isArray(p1)) {
|
|
138
74
|
const given = p1;
|
|
139
|
-
if (!
|
|
75
|
+
if (!(0, type_1.isText)(name)) {
|
|
140
76
|
name = given.map(item => item.split('.').pop()).join('.');
|
|
141
77
|
}
|
|
142
|
-
fields.push(...given.map(f =>
|
|
78
|
+
fields.push(...given.map(f => conn.f(f)));
|
|
143
79
|
}
|
|
144
80
|
else {
|
|
145
81
|
fields.push(p1);
|
|
146
82
|
name = p1;
|
|
147
83
|
}
|
|
148
84
|
name = this._indexName(name);
|
|
149
|
-
sql = `CREATE INDEX ${
|
|
150
|
-
yield
|
|
85
|
+
sql = `CREATE INDEX ${conn.f(name)} ON ${full} (${fields.join(', ')}) IF NOT EXISTS`;
|
|
86
|
+
yield conn.one(this.$def, sql, {
|
|
87
|
+
name: `${path}.index`,
|
|
88
|
+
ignoredErrors: [couchbase_1.IndexExistsError.name]
|
|
89
|
+
});
|
|
151
90
|
});
|
|
152
91
|
}
|
|
92
|
+
// noinspection JSUnusedGlobalSymbols
|
|
153
93
|
/**
|
|
154
94
|
* Execute the creation of indexes with keys
|
|
155
95
|
* */
|
|
@@ -165,9 +105,7 @@ class CbRepo {
|
|
|
165
105
|
return true;
|
|
166
106
|
})
|
|
167
107
|
.map(k => this._createIndex(k));
|
|
168
|
-
|
|
169
|
-
promises.push(this._createPk());
|
|
170
|
-
}
|
|
108
|
+
promises.push(this._createPk());
|
|
171
109
|
if (promises.length > 0) {
|
|
172
110
|
yield Promise.all(promises);
|
|
173
111
|
}
|
|
@@ -178,246 +116,519 @@ class CbRepo {
|
|
|
178
116
|
* */
|
|
179
117
|
_createPk() {
|
|
180
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
119
|
+
const { full, path, conn } = this._props;
|
|
120
|
+
const sql = `CREATE PRIMARY INDEX \`pk\` ON ${full} IF NOT EXISTS`;
|
|
121
|
+
yield conn.one(this.$def, sql, {
|
|
122
|
+
name: `${path}.pk`,
|
|
123
|
+
ignoredErrors: [couchbase_1.IndexExistsError.name]
|
|
124
|
+
});
|
|
186
125
|
});
|
|
187
126
|
}
|
|
188
127
|
/** @inheritDoc */
|
|
189
|
-
|
|
190
|
-
return this
|
|
128
|
+
_afterConnected() {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const { _props: props } = this;
|
|
131
|
+
props.cluster = props.conn.props.cluster;
|
|
132
|
+
yield this._loadBucket();
|
|
133
|
+
yield this._loadScope();
|
|
134
|
+
yield this._loadCollection();
|
|
135
|
+
props.path = `${props.bucket.name}.${props.scope.name}.${props.collection.name}`;
|
|
136
|
+
props.full = props.conn.f(props.path);
|
|
137
|
+
if (props.createIndices) {
|
|
138
|
+
yield this.$createIndices();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
191
141
|
}
|
|
192
|
-
|
|
193
|
-
onModuleInit() {
|
|
142
|
+
_loadBucket() {
|
|
194
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (config_1.couchbaseCommonConfig.raw.CB_CREATE_INDICES) {
|
|
206
|
-
yield this._createIndices();
|
|
144
|
+
const { _props: props } = this;
|
|
145
|
+
(0, type_2.assertText)(props.bucketName, { field: 'bucket', where: 'CbRepo', method: '_loadBucket' });
|
|
146
|
+
let spec = Array.from(CbRepo._specs.keys())
|
|
147
|
+
.find(s => s.name === props.bucketName);
|
|
148
|
+
if (!spec) {
|
|
149
|
+
const bucketManager = props.cluster.buckets();
|
|
150
|
+
const allBuckets = yield bucketManager.getAllBuckets();
|
|
151
|
+
spec = allBuckets.find(b => b.name === props.bucketName);
|
|
152
|
+
if (!spec) {
|
|
153
|
+
throw new cb_schema_error_1.CbSchemaError('Bucket', props.bucketName, 'CbRepo', '_loadBucket');
|
|
207
154
|
}
|
|
155
|
+
CbRepo._specs.set(spec, []);
|
|
208
156
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
157
|
+
const ins = props.cluster.bucket(props.bucketName);
|
|
158
|
+
ins.$spec = spec;
|
|
159
|
+
props.bucket = ins;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
_loadScope() {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const { _props: props } = this;
|
|
165
|
+
(0, type_2.assertText)(props.scopeName, { field: 'scopeName', where: 'CbRepo', method: '_loadScope' });
|
|
166
|
+
let spec = CbRepo._specs.get(props.bucket.$spec)
|
|
167
|
+
.find(s => s.name === props.scopeName);
|
|
168
|
+
if (!spec) {
|
|
169
|
+
const scopeManager = props.bucket.collections();
|
|
170
|
+
const allScopes = yield scopeManager.getAllScopes();
|
|
171
|
+
spec = allScopes.find(s => s.name === props.scopeName);
|
|
172
|
+
if (!spec) {
|
|
173
|
+
throw new cb_schema_error_1.CbSchemaError('Scope', `${props.bucketName}.${props.scopeName}`, 'CbRepo', '_loadScope');
|
|
212
174
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
175
|
+
CbRepo._specs.get(props.bucket.$spec).push(spec);
|
|
176
|
+
}
|
|
177
|
+
const ins = props.bucket.scope(props.scopeName);
|
|
178
|
+
ins.$spec = spec;
|
|
179
|
+
props.scope = ins;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
_loadCollection() {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
const { _props: props } = this;
|
|
185
|
+
(0, type_2.assertText)(props.collectionName, { field: 'collectionName', where: 'CbRepo', method: '_loadCollection' });
|
|
186
|
+
const spec = props.scope.$spec.collections
|
|
187
|
+
.find(s => s.name === props.collectionName);
|
|
188
|
+
if (!spec) {
|
|
189
|
+
throw new cb_schema_error_1.CbSchemaError('Collection', `${props.bucketName}.${props.scopeName}.${props.collectionName}`, 'CbRepo', '_loadCollection');
|
|
217
190
|
}
|
|
191
|
+
const ins = props.scope.collection(props.collectionName);
|
|
192
|
+
ins.$spec = spec;
|
|
193
|
+
props.collection = ins;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Create indices in final repo
|
|
198
|
+
* */
|
|
199
|
+
$createIndices() {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
// can be overloaded
|
|
218
202
|
});
|
|
219
203
|
}
|
|
204
|
+
// endregion protected-method
|
|
205
|
+
// region getter
|
|
206
|
+
/** @inheritDoc */
|
|
207
|
+
get $def() {
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
/** @inheritDoc */
|
|
211
|
+
get props() {
|
|
212
|
+
return this._props;
|
|
213
|
+
}
|
|
214
|
+
// endregion getter
|
|
215
|
+
// region get
|
|
220
216
|
/** @inheritDoc */
|
|
221
|
-
|
|
217
|
+
$getByPrimary(key, p1, ignoreCheck) {
|
|
222
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
219
|
+
if (!ignoreCheck) {
|
|
220
|
+
(0, type_2.assertText)(key, { field: 'id', where: 'CbRepo', method: '$getByPrimary' });
|
|
221
|
+
}
|
|
222
|
+
const { conn, useSoftDelete, collection, full } = this._props;
|
|
223
|
+
const opt = conn.buildOpt(p1, '$getById');
|
|
224
|
+
if (!useSoftDelete) {
|
|
225
|
+
if (!Array.isArray(opt.ignoredErrors)) {
|
|
226
|
+
opt.ignoredErrors = [];
|
|
227
|
+
}
|
|
228
|
+
opt.ignoredErrors.push(couchbase_1.DocumentNotFoundError.name);
|
|
229
|
+
const result = yield conn.exec(collection.get(key, opt), opt);
|
|
230
|
+
return result === null || result === void 0 ? void 0 : result.content;
|
|
231
|
+
}
|
|
232
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
227
233
|
lines
|
|
228
|
-
.add(`SELECT
|
|
229
|
-
.add(`FROM ${
|
|
230
|
-
.add(`
|
|
231
|
-
.add(`
|
|
234
|
+
.add(`SELECT a.*`)
|
|
235
|
+
.add(`FROM ${full} a`)
|
|
236
|
+
.add(`USE KEYS $key`)
|
|
237
|
+
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
232
238
|
.add('LIMIT 1');
|
|
233
|
-
|
|
239
|
+
const parameters = { key };
|
|
240
|
+
return (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row;
|
|
234
241
|
});
|
|
235
242
|
}
|
|
236
243
|
/** @inheritDoc */
|
|
237
|
-
|
|
244
|
+
$getBySecondary(key, p1, ignoreCheck) {
|
|
238
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
246
|
+
const { conn, useSoftDelete, useNumericId, full } = this._props;
|
|
247
|
+
if (!ignoreCheck) {
|
|
248
|
+
if (useNumericId) {
|
|
249
|
+
(0, type_1.assertInteger)(key, { field: 'key', where: 'CbRepo', method: '$getBySecondary' });
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$getBySecondary' });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const opt = conn.buildOpt(p1, '$getBySecondary');
|
|
256
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
243
257
|
lines
|
|
244
|
-
.add(`SELECT
|
|
245
|
-
.add(`FROM ${
|
|
246
|
-
.add(`
|
|
247
|
-
.
|
|
258
|
+
.add(`SELECT a.*`)
|
|
259
|
+
.add(`FROM ${full} a`)
|
|
260
|
+
.add(`WHERE (a.${F_ID} = $key)`)
|
|
261
|
+
.no(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`)
|
|
248
262
|
.add('LIMIT 1');
|
|
249
|
-
|
|
263
|
+
const parameters = { key };
|
|
264
|
+
return (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row;
|
|
250
265
|
});
|
|
251
266
|
}
|
|
267
|
+
// endregion get
|
|
268
|
+
// region exists
|
|
252
269
|
/** @inheritDoc */
|
|
253
|
-
|
|
270
|
+
$existsByPrimary(key, p1, ignoreCheck) {
|
|
254
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
-
|
|
256
|
-
|
|
272
|
+
var _a, _b, _c;
|
|
273
|
+
if (!ignoreCheck) {
|
|
274
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$existsByPrimary' });
|
|
275
|
+
}
|
|
276
|
+
const { useSoftDelete, conn, collection, full } = this._props;
|
|
277
|
+
const opt = conn.buildOpt(p1, '$existsByPrimary');
|
|
278
|
+
if (!useSoftDelete) {
|
|
279
|
+
return (_b = (_a = (yield conn.exec(collection.exists(key, opt), opt))) === null || _a === void 0 ? void 0 : _a.exists) !== null && _b !== void 0 ? _b : false;
|
|
280
|
+
}
|
|
281
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
282
|
+
lines
|
|
283
|
+
.add(`SELECT meta().id \`x\``)
|
|
284
|
+
.add(`FROM ${full} a`)
|
|
285
|
+
.add(`USE KEYS $key`)
|
|
286
|
+
.add(`WHERE (a.${F_TRASH_ID} is missing)`)
|
|
287
|
+
.add('LIMIT 1');
|
|
288
|
+
const parameters = { key };
|
|
289
|
+
return ((_c = (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _c === void 0 ? void 0 : _c.x) === undefined;
|
|
257
290
|
});
|
|
258
291
|
}
|
|
259
292
|
/** @inheritDoc */
|
|
260
|
-
|
|
293
|
+
$existsBySecondary(key, p1, ignoreCheck) {
|
|
261
294
|
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
|
|
295
|
+
var _a;
|
|
296
|
+
const { useSoftDelete, useNumericId, conn, full } = this._props;
|
|
297
|
+
if (!ignoreCheck) {
|
|
298
|
+
if (useNumericId) {
|
|
299
|
+
(0, type_1.assertInteger)(key, { field: 'key', where: 'CbRepo', method: '$existsBySecondary' });
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$existsBySecondary' });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const opt = conn.buildOpt(p1, '$existsBySecondary');
|
|
306
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
265
307
|
lines
|
|
266
|
-
.add(`SELECT
|
|
267
|
-
.add(`FROM ${
|
|
268
|
-
.add(`USE KEYS $
|
|
269
|
-
.
|
|
308
|
+
.add(`SELECT meta().id \`x\``)
|
|
309
|
+
.add(`FROM ${full} a`)
|
|
310
|
+
.add(`USE KEYS $key`)
|
|
311
|
+
.yes(useSoftDelete, `WHERE (a.${F_TRASH_ID} IS MISSING)`)
|
|
270
312
|
.add('LIMIT 1');
|
|
271
|
-
|
|
313
|
+
const parameters = { key };
|
|
314
|
+
return ((_a = (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x) === undefined;
|
|
272
315
|
});
|
|
273
316
|
}
|
|
317
|
+
// endregion exists
|
|
318
|
+
// region list
|
|
274
319
|
/** @inheritDoc */
|
|
275
|
-
|
|
320
|
+
$listByPrimary(keys, p1, ignoreCheck) {
|
|
276
321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
322
|
+
if (!ignoreCheck) {
|
|
323
|
+
(0, type_2.assertArray)(keys, { field: 'keys', where: 'CbRepo', method: '$listByPrimary' });
|
|
324
|
+
keys.forEach((key, index) => {
|
|
325
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$listByPrimary', index });
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
const { useSoftDelete, conn, full } = this._props;
|
|
329
|
+
const opt = conn.buildOpt(p1, '$listByIds');
|
|
330
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
280
331
|
lines
|
|
281
332
|
.add(`SELECT a.*`)
|
|
282
|
-
.add(`FROM ${
|
|
283
|
-
.add(`
|
|
284
|
-
.
|
|
285
|
-
|
|
286
|
-
return (yield
|
|
333
|
+
.add(`FROM ${full} a`)
|
|
334
|
+
.add(`USE KEYS $keys`)
|
|
335
|
+
.yes(useSoftDelete, `WHERE (a.${F_TRASH_ID} is missing)`);
|
|
336
|
+
const parameters = { keys };
|
|
337
|
+
return (yield conn.more(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).rows;
|
|
287
338
|
});
|
|
288
339
|
}
|
|
289
340
|
/** @inheritDoc */
|
|
290
|
-
|
|
341
|
+
$listBySecondary(keys, p1, ignoreCheck) {
|
|
291
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
343
|
+
const { useSoftDelete, useNumericId, conn, full } = this._props;
|
|
344
|
+
if (!ignoreCheck) {
|
|
345
|
+
(0, type_2.assertArray)(keys, { field: 'keys', where: 'CbRepo', method: '$listBySecondary' });
|
|
346
|
+
keys.forEach((key, index) => {
|
|
347
|
+
if (useNumericId) {
|
|
348
|
+
(0, type_1.assertInteger)(key, { field: 'key', where: 'CbRepo', method: '$listBySecondary', index });
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$listBySecondary', index });
|
|
352
|
+
}
|
|
353
|
+
});
|
|
297
354
|
}
|
|
298
|
-
const
|
|
355
|
+
const opt = conn.buildOpt(p1, '$listBySecondary');
|
|
356
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
299
357
|
lines
|
|
300
358
|
.add(`SELECT a.*`)
|
|
301
|
-
.add(`FROM ${
|
|
302
|
-
.add(`
|
|
303
|
-
.
|
|
304
|
-
|
|
359
|
+
.add(`FROM ${full} a`)
|
|
360
|
+
.add(`WHERE (a.${F_ID} IN $keys)`)
|
|
361
|
+
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} IS MISSING)`);
|
|
362
|
+
const parameters = { keys };
|
|
363
|
+
return (yield conn.more(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).rows;
|
|
305
364
|
});
|
|
306
365
|
}
|
|
366
|
+
// endregion list
|
|
367
|
+
// region filter
|
|
307
368
|
/** @inheritDoc */
|
|
308
|
-
|
|
369
|
+
$filter(query, p1) {
|
|
309
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
-
const
|
|
311
|
-
const opt =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return [];
|
|
315
|
-
}
|
|
316
|
-
const lines = (0, line_1.cbLine)();
|
|
371
|
+
const { useSoftDelete, conn, full } = this._props;
|
|
372
|
+
const opt = conn.buildOpt(p1, '$filter');
|
|
373
|
+
// @todo - work for query builder
|
|
374
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
317
375
|
lines
|
|
318
376
|
.add(`SELECT a.*`)
|
|
319
|
-
.add(`FROM ${
|
|
320
|
-
.
|
|
321
|
-
|
|
322
|
-
return (yield cb.more(this, lines.end(), opt)).rows;
|
|
377
|
+
.add(`FROM ${full} a`)
|
|
378
|
+
.both(useSoftDelete, `WHERE (a.${F_TRASH_ID} is missing)`, `WHERE (meta().id is not missing)`);
|
|
379
|
+
return (yield conn.more(this.$def, lines.end(), opt)).rows;
|
|
323
380
|
});
|
|
324
381
|
}
|
|
382
|
+
// endregion filter
|
|
383
|
+
// region insert
|
|
325
384
|
/** @inheritDoc */
|
|
326
|
-
|
|
385
|
+
$insert(doc, p1, ignoreCheck) {
|
|
327
386
|
return __awaiter(this, void 0, void 0, function* () {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
387
|
+
const { conn, collection, useNumericId } = this._props;
|
|
388
|
+
if (!ignoreCheck) {
|
|
389
|
+
(0, type_2.assertObject)(doc, { field: 'doc', where: 'CbRepo', method: '$insert' });
|
|
390
|
+
(0, type_2.assertText)(doc._urn, { field: 'doc._urn', where: 'CbRepo', method: '$insert' });
|
|
391
|
+
if (useNumericId) {
|
|
392
|
+
(0, type_1.assertInteger)(doc.id, { field: 'doc.id', where: 'CbRepo', method: '$insert' });
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
(0, type_2.assertText)(doc.id, { field: 'doc.id', where: 'CbRepo', method: '$insert' });
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const opt = conn.buildOpt(p1, '$insert');
|
|
399
|
+
yield conn.exec(collection.insert(doc._urn, doc), opt);
|
|
400
|
+
return doc._urn;
|
|
339
401
|
});
|
|
340
402
|
}
|
|
403
|
+
// endregion insert
|
|
404
|
+
// region replace
|
|
341
405
|
/** @inheritDoc */
|
|
342
|
-
|
|
406
|
+
$replace(doc, p1, ignoreCheck) {
|
|
343
407
|
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
408
|
+
const { conn, collection, useNumericId } = this._props;
|
|
409
|
+
if (!ignoreCheck) {
|
|
410
|
+
(0, type_2.assertObject)(doc, { field: 'doc', where: 'CbRepo', method: '$replace' });
|
|
411
|
+
(0, type_2.assertText)(doc._urn, { field: 'doc._urn', where: 'CbRepo', method: '$replace' });
|
|
412
|
+
if (useNumericId) {
|
|
413
|
+
(0, type_1.assertInteger)(doc.id, { field: 'doc.id', where: 'CbRepo', method: '$replace' });
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
(0, type_2.assertText)(doc.id, { field: 'doc.id', where: 'CbRepo', method: '$replace' });
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const opt = conn.buildOpt(p1, '$replace');
|
|
420
|
+
yield conn.exec(collection.replace(doc._urn, doc), opt);
|
|
421
|
+
return doc._urn;
|
|
354
422
|
});
|
|
355
423
|
}
|
|
424
|
+
// endregion replace
|
|
425
|
+
// region update
|
|
356
426
|
/** @inheritDoc */
|
|
357
|
-
|
|
427
|
+
$updateByPrimary(key, doc, p1, ignoreCheck) {
|
|
358
428
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
429
|
+
if (!ignoreCheck) {
|
|
430
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$updateByPrimary' });
|
|
431
|
+
(0, type_2.assertObject)(doc, { field: 'doc', where: 'CbRepo', method: '$updateByPrimary' });
|
|
432
|
+
}
|
|
433
|
+
const { conn, full, useSoftDelete } = this._props;
|
|
434
|
+
const opt = conn.buildOpt(p1, '$updateByPrimary');
|
|
435
|
+
const parameters = {};
|
|
436
|
+
let paramId = 0;
|
|
437
|
+
const set = [];
|
|
438
|
+
const unset = [];
|
|
439
|
+
for (const [k, v] of Object.entries(doc)) {
|
|
440
|
+
if (v === undefined) {
|
|
441
|
+
unset.push('a.' + conn.f(k));
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
set.push(['a.' + conn.f(k), '$param_' + paramId]);
|
|
445
|
+
parameters['param_' + paramId] = v;
|
|
446
|
+
paramId++;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (set.length > 0 || unset.length > 0) {
|
|
450
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
451
|
+
lines.add(`UPDATE ${full} a`);
|
|
452
|
+
lines.add(`USE KEYS $key`);
|
|
453
|
+
parameters['key'] = key;
|
|
454
|
+
if (set.length > 0) {
|
|
455
|
+
lines.add('SET').add(set.join(',\n '));
|
|
456
|
+
}
|
|
457
|
+
if (unset.length > 0) {
|
|
458
|
+
lines.add('UNSET').add(unset.join(', '));
|
|
459
|
+
}
|
|
460
|
+
lines
|
|
461
|
+
.yes(useSoftDelete, `WHERE (a.${F_TRASH_ID} is missing)`);
|
|
462
|
+
yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }));
|
|
463
|
+
return key;
|
|
464
|
+
}
|
|
465
|
+
return undefined;
|
|
366
466
|
});
|
|
367
467
|
}
|
|
368
468
|
/** @inheritDoc */
|
|
369
|
-
|
|
469
|
+
$updateBySecondary(key, doc, p1, ignoreCheck) {
|
|
370
470
|
return __awaiter(this, void 0, void 0, function* () {
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
471
|
+
var _a;
|
|
472
|
+
const { useNumericId, useSoftDelete, conn, full } = this._props;
|
|
473
|
+
if (!ignoreCheck) {
|
|
474
|
+
if (useNumericId) {
|
|
475
|
+
(0, type_1.assertInteger)(key, { field: 'key', where: 'CbRepo', method: '$updateBySecondary' });
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$updateBySecondary' });
|
|
479
|
+
}
|
|
480
|
+
(0, type_2.assertObject)(doc, { field: 'doc', where: 'CbRepo', method: '$updateBySecondary' });
|
|
481
|
+
}
|
|
482
|
+
const opt = conn.buildOpt(p1, '$updateBySecondary');
|
|
483
|
+
const parameters = {};
|
|
484
|
+
let paramId = 0;
|
|
485
|
+
const set = [];
|
|
486
|
+
const unset = [];
|
|
487
|
+
for (const [k, v] of Object.entries(doc)) {
|
|
488
|
+
if (v === undefined) {
|
|
489
|
+
unset.push('a.' + conn.f(k));
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
set.push(['a.' + conn.f(k), '$param_' + paramId]);
|
|
493
|
+
parameters['param_' + paramId] = v;
|
|
494
|
+
paramId++;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (set.length > 0 || unset.length > 0) {
|
|
498
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
499
|
+
lines.add(`UPDATE ${full} a`);
|
|
500
|
+
if (set.length > 0) {
|
|
501
|
+
lines.add('SET').add(set.join(',\n '));
|
|
502
|
+
}
|
|
503
|
+
if (unset.length > 0) {
|
|
504
|
+
lines.add('UNSET').add(unset.join(', '));
|
|
505
|
+
}
|
|
506
|
+
lines
|
|
507
|
+
.add(`WHERE (a.${F_ID} = $key)`)
|
|
508
|
+
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`);
|
|
509
|
+
parameters['key'] = key;
|
|
510
|
+
lines.add('RETURNING meta().id \`x\`');
|
|
511
|
+
return (_a = (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x;
|
|
512
|
+
}
|
|
513
|
+
return undefined;
|
|
377
514
|
});
|
|
378
515
|
}
|
|
516
|
+
// endregion update
|
|
517
|
+
// region remove
|
|
379
518
|
/** @inheritDoc */
|
|
380
|
-
|
|
519
|
+
$removeByPrimary(key, p1, ignoreCheck) {
|
|
381
520
|
return __awaiter(this, void 0, void 0, function* () {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
521
|
+
if (!ignoreCheck) {
|
|
522
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$removeByPrimary' });
|
|
523
|
+
}
|
|
524
|
+
const { useSoftDelete, conn, full, collection } = this._props;
|
|
525
|
+
const opt = conn.buildOpt(p1, '$removeByPrimary');
|
|
526
|
+
if (!useSoftDelete) {
|
|
527
|
+
yield conn.exec(collection.remove(key, opt), opt);
|
|
528
|
+
return key;
|
|
529
|
+
}
|
|
530
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
531
|
+
lines
|
|
532
|
+
.add('DELETE')
|
|
533
|
+
.add(`FROM ${full} a`)
|
|
534
|
+
.add(`USE KEYS $key`)
|
|
535
|
+
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`);
|
|
536
|
+
const parameters = { key };
|
|
537
|
+
yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }));
|
|
538
|
+
return key;
|
|
388
539
|
});
|
|
389
540
|
}
|
|
390
541
|
/** @inheritDoc */
|
|
391
|
-
|
|
542
|
+
$removeBySecondary(key, p1, ignoreCheck) {
|
|
392
543
|
return __awaiter(this, void 0, void 0, function* () {
|
|
393
544
|
var _a;
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
545
|
+
const { useNumericId, useSoftDelete, conn, full } = this._props;
|
|
546
|
+
if (!ignoreCheck) {
|
|
547
|
+
if (useNumericId) {
|
|
548
|
+
(0, type_1.assertInteger)(key, { field: 'key', where: 'CbRepo', method: '$removeBySecondary' });
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$removeBySecondary' });
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
const opt = conn.buildOpt(p1, '$removeBySecondary');
|
|
555
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
556
|
+
lines
|
|
557
|
+
.add('DELETE')
|
|
558
|
+
.add(`FROM ${full} a`)
|
|
559
|
+
.add(`WHERE (a.${F_ID} = $key)`)
|
|
560
|
+
.yes(useSoftDelete, ` AND (a.${F_TRASH_ID} is missing)`)
|
|
561
|
+
.add('RETURNING meta().id \`x\`');
|
|
562
|
+
const parameters = { key };
|
|
563
|
+
return (_a = (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x;
|
|
401
564
|
});
|
|
402
565
|
}
|
|
566
|
+
// endregion remove
|
|
567
|
+
// region trash
|
|
403
568
|
/** @inheritDoc */
|
|
404
|
-
|
|
569
|
+
$trashByPrimary(key, p1, ignoreCheck) {
|
|
405
570
|
return __awaiter(this, void 0, void 0, function* () {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (opt.trashId === undefined) {
|
|
410
|
-
opt.trashId = (0, node_crypto_1.randomUUID)();
|
|
571
|
+
const { useSoftDelete, conn, full } = this._props;
|
|
572
|
+
if (!useSoftDelete) {
|
|
573
|
+
throw new be_db_common_1.DbNotSupportedError('Soft delete', 'CbRepo', '$trashByPrimary');
|
|
411
574
|
}
|
|
412
|
-
|
|
575
|
+
if (!ignoreCheck) {
|
|
576
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$trashByPrimary' });
|
|
577
|
+
}
|
|
578
|
+
const opt = conn.buildOpt(p1, '$trashByPrimary');
|
|
579
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
413
580
|
lines
|
|
414
|
-
.add(`UPDATE ${
|
|
415
|
-
.add(`
|
|
416
|
-
.add(`
|
|
581
|
+
.add(`UPDATE ${full} a`)
|
|
582
|
+
.add(`SET`)
|
|
583
|
+
.add(` \`updatedAt\` = $updated,`)
|
|
584
|
+
.add(` ${F_TRASH_ID} = $trashId`)
|
|
585
|
+
.add(`USE KEYS $key`)
|
|
417
586
|
.add(`WHERE (a.${F_TRASH_ID} is missing)`);
|
|
418
|
-
|
|
419
|
-
|
|
587
|
+
const parameters = {
|
|
588
|
+
updated: this._now,
|
|
589
|
+
trashId: opt.trashId,
|
|
590
|
+
key,
|
|
591
|
+
};
|
|
592
|
+
yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }));
|
|
593
|
+
return key;
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
/** @inheritDoc */
|
|
597
|
+
$trashBySecondary(key, p1, ignoreCheck) {
|
|
598
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
599
|
+
var _a;
|
|
600
|
+
const { useSoftDelete, useNumericId, conn, full } = this._props;
|
|
601
|
+
if (!useSoftDelete) {
|
|
602
|
+
throw new be_db_common_1.DbNotSupportedError('Soft delete', 'CbRepo', '$trashBySecondary');
|
|
603
|
+
}
|
|
604
|
+
if (!ignoreCheck) {
|
|
605
|
+
if (useNumericId) {
|
|
606
|
+
(0, type_1.assertInteger)(key, { field: 'key', where: 'CbRepo', method: '$trashBySecondary' });
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
(0, type_2.assertText)(key, { field: 'key', where: 'CbRepo', method: '$trashBySecondary' });
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const opt = conn.buildOpt(p1, '$trashBySecondary');
|
|
613
|
+
const lines = (0, be_db_common_1.dbLines)();
|
|
614
|
+
lines
|
|
615
|
+
.add(`UPDATE ${full} a`)
|
|
616
|
+
.add(`SET`)
|
|
617
|
+
.add(` \`updatedAt\` = $updated,`)
|
|
618
|
+
.add(` ${F_TRASH_ID} = $trashId`)
|
|
619
|
+
.add(`WHERE (a.${F_ID} = $key)`)
|
|
620
|
+
.add(` AND (a.${F_TRASH_ID} is missing)`)
|
|
621
|
+
.add('RETURNING meta().id \`x\`');
|
|
622
|
+
const parameters = {
|
|
623
|
+
updated: this._now,
|
|
624
|
+
trashId: opt.trashId,
|
|
625
|
+
key,
|
|
626
|
+
};
|
|
627
|
+
return (_a = (yield conn.one(this.$def, lines.end(), Object.assign(Object.assign({}, opt), { parameters }))).row) === null || _a === void 0 ? void 0 : _a.x;
|
|
420
628
|
});
|
|
421
629
|
}
|
|
422
630
|
}
|
|
423
631
|
exports.CbRepo = CbRepo;
|
|
632
|
+
// region private-property
|
|
633
|
+
// {bucket: scope[]}
|
|
634
|
+
CbRepo._specs = new Map;
|