mocody 0.4.9 → 0.4.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/couch/couch-manage-table.js +1 -0
- package/dist/couch/couch-manage-table.js.map +1 -1
- package/dist/helpers/util-service.js +2 -2
- package/dist/helpers/util-service.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/pouch/pouch-data-operation.d.ts +105 -0
- package/dist/pouch/pouch-data-operation.js +609 -0
- package/dist/pouch/pouch-data-operation.js.map +1 -0
- package/dist/pouch/pouch-filter-query-operation.d.ts +47 -0
- package/dist/pouch/pouch-filter-query-operation.js +439 -0
- package/dist/pouch/pouch-filter-query-operation.js.map +1 -0
- package/dist/pouch/pouch-initializer.d.ts +102 -0
- package/dist/pouch/pouch-initializer.js +258 -0
- package/dist/pouch/pouch-initializer.js.map +1 -0
- package/dist/pouch/pouch-manage-table.d.ts +47 -0
- package/dist/pouch/pouch-manage-table.js +117 -0
- package/dist/pouch/pouch-manage-table.js.map +1 -0
- package/package.json +21 -21
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { IMocodyQueryDefinition } from "../type";
|
|
2
|
+
interface ISelectedQueryConditionsKeys {
|
|
3
|
+
$lt?: any;
|
|
4
|
+
$gt?: any;
|
|
5
|
+
$lte?: any;
|
|
6
|
+
$gte?: any;
|
|
7
|
+
$eq?: any;
|
|
8
|
+
$ne?: any;
|
|
9
|
+
$not?: any;
|
|
10
|
+
$exists?: boolean;
|
|
11
|
+
$in?: any[];
|
|
12
|
+
$nin?: any[];
|
|
13
|
+
$regex?: string;
|
|
14
|
+
$elemMatch?: {
|
|
15
|
+
$in: any[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type FieldPartialQuery<T> = {
|
|
19
|
+
[P in keyof T]-?: T[P];
|
|
20
|
+
};
|
|
21
|
+
type IQueryConditions = {
|
|
22
|
+
[fieldName: string]: FieldPartialQuery<ISelectedQueryConditionsKeys>;
|
|
23
|
+
};
|
|
24
|
+
export declare class PouchFilterQueryOperation {
|
|
25
|
+
private operation__filterFieldExist;
|
|
26
|
+
private operation__filterFieldNotExist;
|
|
27
|
+
private operation__helperFilterBasic;
|
|
28
|
+
private operation__filterIn;
|
|
29
|
+
private operation__filterNotIn;
|
|
30
|
+
private operation__filterNot;
|
|
31
|
+
private operation__filterElementMatch;
|
|
32
|
+
private operation__filterContains;
|
|
33
|
+
private operation__filterNotContains;
|
|
34
|
+
private operation__filterBetween;
|
|
35
|
+
private operation__filterBeginsWith;
|
|
36
|
+
private operation__filterNestedMatchObject;
|
|
37
|
+
private operation__translateAdvancedQueryOperation;
|
|
38
|
+
private operation_translateBasicQueryOperation;
|
|
39
|
+
processQueryFilter({ queryDefs }: {
|
|
40
|
+
queryDefs: IMocodyQueryDefinition<any>["query"];
|
|
41
|
+
}): IQueryConditions & {
|
|
42
|
+
$and: IQueryConditions[];
|
|
43
|
+
} & {
|
|
44
|
+
$or: IQueryConditions[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PouchFilterQueryOperation = void 0;
|
|
4
|
+
const errors_1 = require("../helpers/errors");
|
|
5
|
+
const query_validator_1 = require("../helpers/query-validator");
|
|
6
|
+
const KEY_CONDITION_MAP = {
|
|
7
|
+
$eq: "$eq",
|
|
8
|
+
$lt: "$lt",
|
|
9
|
+
$lte: "$lte",
|
|
10
|
+
$gt: "$gt",
|
|
11
|
+
$gte: "$gte",
|
|
12
|
+
$between: "",
|
|
13
|
+
$beginsWith: "",
|
|
14
|
+
};
|
|
15
|
+
const QUERY_CONDITION_MAP_PART = {
|
|
16
|
+
$ne: "$ne",
|
|
17
|
+
$exists: "",
|
|
18
|
+
$in: "",
|
|
19
|
+
$nin: "",
|
|
20
|
+
$not: "",
|
|
21
|
+
$contains: "",
|
|
22
|
+
$notContains: "",
|
|
23
|
+
$elemMatch: "",
|
|
24
|
+
$nestedMatch: "",
|
|
25
|
+
};
|
|
26
|
+
const QUERY_CONDITION_MAP_FULL = { ...KEY_CONDITION_MAP, ...QUERY_CONDITION_MAP_PART };
|
|
27
|
+
function hasQueryKeyCondition(key) {
|
|
28
|
+
return Object.keys(KEY_CONDITION_MAP).includes(key);
|
|
29
|
+
}
|
|
30
|
+
function getQueryConditionExpression(key) {
|
|
31
|
+
if (key && Object.keys(QUERY_CONDITION_MAP_FULL).includes(key)) {
|
|
32
|
+
const conditionExpr = QUERY_CONDITION_MAP_FULL[key];
|
|
33
|
+
if (conditionExpr) {
|
|
34
|
+
return conditionExpr;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
function regex_pcre_beginWith(text) {
|
|
40
|
+
return `(?i)\\A${text}`;
|
|
41
|
+
}
|
|
42
|
+
function regex_pcre_contain(text) {
|
|
43
|
+
return `(?i)${text}`;
|
|
44
|
+
}
|
|
45
|
+
class PouchFilterQueryOperation {
|
|
46
|
+
operation__filterFieldExist({ fieldName }) {
|
|
47
|
+
const result = {
|
|
48
|
+
[fieldName]: { $exists: true },
|
|
49
|
+
};
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
operation__filterFieldNotExist({ fieldName }) {
|
|
53
|
+
const result = {
|
|
54
|
+
[fieldName]: { $exists: false },
|
|
55
|
+
};
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
operation__helperFilterBasic({ fieldName, val, conditionExpr, }) {
|
|
59
|
+
if (conditionExpr) {
|
|
60
|
+
return {
|
|
61
|
+
[fieldName]: { [conditionExpr]: val },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const result = {
|
|
65
|
+
[fieldName]: { $eq: val },
|
|
66
|
+
};
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
operation__filterIn({ fieldName, attrValues }) {
|
|
70
|
+
const result = {
|
|
71
|
+
[fieldName]: { $in: attrValues },
|
|
72
|
+
};
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
operation__filterNotIn({ fieldName, attrValues, }) {
|
|
76
|
+
const result = {
|
|
77
|
+
[fieldName]: { $nin: attrValues },
|
|
78
|
+
};
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
operation__filterNot({ fieldName, selectorObjValues, }) {
|
|
82
|
+
const selector = { ...selectorObjValues };
|
|
83
|
+
const mConditions = [];
|
|
84
|
+
Object.entries(selector).forEach(([conditionKey, conditionValue]) => {
|
|
85
|
+
if (hasQueryKeyCondition(conditionKey)) {
|
|
86
|
+
const _conditionKey01 = conditionKey;
|
|
87
|
+
if (_conditionKey01 === "$beginsWith") {
|
|
88
|
+
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
89
|
+
const _queryConditions = this.operation__filterBeginsWith({
|
|
90
|
+
fieldName: fieldName,
|
|
91
|
+
term: conditionValue,
|
|
92
|
+
});
|
|
93
|
+
mConditions.push(_queryConditions);
|
|
94
|
+
}
|
|
95
|
+
else if (_conditionKey01 === "$between") {
|
|
96
|
+
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
97
|
+
const _queryConditions = this.operation__filterBetween({
|
|
98
|
+
fieldName: fieldName,
|
|
99
|
+
from: conditionValue[0],
|
|
100
|
+
to: conditionValue[1],
|
|
101
|
+
});
|
|
102
|
+
mConditions.push(_queryConditions);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const conditionExpr = KEY_CONDITION_MAP[conditionKey];
|
|
106
|
+
if (conditionExpr) {
|
|
107
|
+
const _queryConditions = this.operation__helperFilterBasic({
|
|
108
|
+
fieldName: fieldName,
|
|
109
|
+
val: conditionValue,
|
|
110
|
+
conditionExpr: conditionExpr,
|
|
111
|
+
});
|
|
112
|
+
mConditions.push(_queryConditions);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
query_validator_1.QueryValidatorCheck.throwQueryNotFound(conditionKey);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (mConditions.length) {
|
|
121
|
+
let selectorValuesAll = {};
|
|
122
|
+
mConditions.forEach((condition) => {
|
|
123
|
+
selectorValuesAll = { ...selectorValuesAll, ...condition[fieldName] };
|
|
124
|
+
});
|
|
125
|
+
const result = {
|
|
126
|
+
[fieldName]: { $not: selectorValuesAll },
|
|
127
|
+
};
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
operation__filterElementMatch({ fieldName, attrValues, }) {
|
|
133
|
+
const result = {
|
|
134
|
+
[fieldName]: {
|
|
135
|
+
$elemMatch: attrValues,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
operation__filterContains({ fieldName, term }) {
|
|
141
|
+
const result = {
|
|
142
|
+
[fieldName]: { $regex: regex_pcre_contain(term) },
|
|
143
|
+
};
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
operation__filterNotContains({ fieldName, term }) {
|
|
147
|
+
const result = {
|
|
148
|
+
[fieldName]: { $not: { $regex: regex_pcre_contain(term) } },
|
|
149
|
+
};
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
operation__filterBetween({ fieldName, from, to, }) {
|
|
153
|
+
const result = {
|
|
154
|
+
[fieldName]: { $gte: from, $lte: to },
|
|
155
|
+
};
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
operation__filterBeginsWith({ fieldName, term }) {
|
|
159
|
+
const result = {
|
|
160
|
+
[fieldName]: { $regex: regex_pcre_beginWith(term) },
|
|
161
|
+
};
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
operation__filterNestedMatchObject({ fieldName, attrValues, }) {
|
|
165
|
+
const results = [];
|
|
166
|
+
Object.entries(attrValues).forEach(([subFieldName, queryval]) => {
|
|
167
|
+
let _queryValue;
|
|
168
|
+
if (queryval && typeof queryval === "object") {
|
|
169
|
+
_queryValue = { ...queryval };
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
_queryValue = { $eq: queryval };
|
|
173
|
+
}
|
|
174
|
+
Object.entries(_queryValue).forEach(([condKey, val]) => {
|
|
175
|
+
const conditionKey = condKey;
|
|
176
|
+
if (!Object.keys(KEY_CONDITION_MAP).includes(conditionKey)) {
|
|
177
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Invalid query key: ${conditionKey} @ NestedMatchObject`);
|
|
178
|
+
}
|
|
179
|
+
const conditionExpr = KEY_CONDITION_MAP[conditionKey];
|
|
180
|
+
if (conditionExpr) {
|
|
181
|
+
const result = {
|
|
182
|
+
[`${fieldName}.${subFieldName}`]: { [conditionExpr]: val },
|
|
183
|
+
};
|
|
184
|
+
results.push(result);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (conditionKey === "$between") {
|
|
188
|
+
if (!(Array.isArray(val) && val.length === 2)) {
|
|
189
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError("$between query must be an array of length 2");
|
|
190
|
+
}
|
|
191
|
+
const [fromVal, toVal] = val;
|
|
192
|
+
const result = {
|
|
193
|
+
[`${fieldName}.${subFieldName}`]: { $gte: fromVal, $lte: toVal },
|
|
194
|
+
};
|
|
195
|
+
results.push(result);
|
|
196
|
+
}
|
|
197
|
+
else if (conditionKey === "$beginsWith") {
|
|
198
|
+
const result = {
|
|
199
|
+
[`${fieldName}.${subFieldName}`]: { $regex: regex_pcre_beginWith(val) },
|
|
200
|
+
};
|
|
201
|
+
results.push(result);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Query key: ${conditionKey} not currently supported`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
return results;
|
|
210
|
+
}
|
|
211
|
+
operation__translateAdvancedQueryOperation({ fieldName, queryObject, }) {
|
|
212
|
+
const queryConditions = [];
|
|
213
|
+
Object.entries(queryObject).forEach(([condKey, conditionValue]) => {
|
|
214
|
+
const conditionKey = condKey;
|
|
215
|
+
if (conditionValue !== undefined) {
|
|
216
|
+
if (conditionKey === "$between") {
|
|
217
|
+
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
218
|
+
const _queryConditions = this.operation__filterBetween({
|
|
219
|
+
fieldName: fieldName,
|
|
220
|
+
from: conditionValue[0],
|
|
221
|
+
to: conditionValue[1],
|
|
222
|
+
});
|
|
223
|
+
queryConditions.push(_queryConditions);
|
|
224
|
+
}
|
|
225
|
+
else if (conditionKey === "$beginsWith") {
|
|
226
|
+
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
227
|
+
const _queryConditions = this.operation__filterBeginsWith({
|
|
228
|
+
fieldName: fieldName,
|
|
229
|
+
term: conditionValue,
|
|
230
|
+
});
|
|
231
|
+
queryConditions.push(_queryConditions);
|
|
232
|
+
}
|
|
233
|
+
else if (conditionKey === "$contains") {
|
|
234
|
+
query_validator_1.QueryValidatorCheck.contains(conditionValue);
|
|
235
|
+
const _queryConditions = this.operation__filterContains({
|
|
236
|
+
fieldName: fieldName,
|
|
237
|
+
term: conditionValue,
|
|
238
|
+
});
|
|
239
|
+
queryConditions.push(_queryConditions);
|
|
240
|
+
}
|
|
241
|
+
else if (conditionKey === "$notContains") {
|
|
242
|
+
query_validator_1.QueryValidatorCheck.notContains(conditionValue);
|
|
243
|
+
const _queryConditions = this.operation__filterNotContains({
|
|
244
|
+
fieldName: fieldName,
|
|
245
|
+
term: conditionValue,
|
|
246
|
+
});
|
|
247
|
+
queryConditions.push(_queryConditions);
|
|
248
|
+
}
|
|
249
|
+
else if (conditionKey === "$in") {
|
|
250
|
+
query_validator_1.QueryValidatorCheck.in_query(conditionValue);
|
|
251
|
+
const _queryConditions = this.operation__filterIn({
|
|
252
|
+
fieldName: fieldName,
|
|
253
|
+
attrValues: conditionValue,
|
|
254
|
+
});
|
|
255
|
+
queryConditions.push(_queryConditions);
|
|
256
|
+
}
|
|
257
|
+
else if (conditionKey === "$nin") {
|
|
258
|
+
query_validator_1.QueryValidatorCheck.notIn(conditionValue);
|
|
259
|
+
const _queryConditions = this.operation__filterNotIn({
|
|
260
|
+
fieldName: fieldName,
|
|
261
|
+
attrValues: conditionValue,
|
|
262
|
+
});
|
|
263
|
+
queryConditions.push(_queryConditions);
|
|
264
|
+
}
|
|
265
|
+
else if (conditionKey === "$elemMatch") {
|
|
266
|
+
query_validator_1.QueryValidatorCheck.elemMatch(conditionValue);
|
|
267
|
+
const _queryConditions = this.operation__filterElementMatch({
|
|
268
|
+
fieldName: fieldName,
|
|
269
|
+
attrValues: conditionValue,
|
|
270
|
+
});
|
|
271
|
+
queryConditions.push(_queryConditions);
|
|
272
|
+
}
|
|
273
|
+
else if (conditionKey === "$nestedMatch") {
|
|
274
|
+
query_validator_1.QueryValidatorCheck.nestedMatch(conditionValue);
|
|
275
|
+
const nestedMatchConditions = this.operation__filterNestedMatchObject({
|
|
276
|
+
fieldName: fieldName,
|
|
277
|
+
attrValues: conditionValue,
|
|
278
|
+
});
|
|
279
|
+
if (nestedMatchConditions?.length) {
|
|
280
|
+
nestedMatchConditions.forEach((_queryCondition) => {
|
|
281
|
+
queryConditions.push(_queryCondition);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (conditionKey === "$not") {
|
|
286
|
+
query_validator_1.QueryValidatorCheck.not_query(conditionValue);
|
|
287
|
+
if (conditionValue && typeof conditionValue === "object") {
|
|
288
|
+
const _queryConditions = this.operation__filterNot({
|
|
289
|
+
fieldName: fieldName,
|
|
290
|
+
selectorObjValues: conditionValue,
|
|
291
|
+
});
|
|
292
|
+
if (_queryConditions) {
|
|
293
|
+
queryConditions.push(_queryConditions);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else if (conditionKey === "$exists") {
|
|
298
|
+
query_validator_1.QueryValidatorCheck.exists(conditionValue);
|
|
299
|
+
if (String(conditionValue) === "true") {
|
|
300
|
+
const _queryConditions = this.operation__filterFieldExist({
|
|
301
|
+
fieldName: fieldName,
|
|
302
|
+
});
|
|
303
|
+
queryConditions.push(_queryConditions);
|
|
304
|
+
}
|
|
305
|
+
else if (String(conditionValue) === "false") {
|
|
306
|
+
const _queryConditions = this.operation__filterFieldNotExist({
|
|
307
|
+
fieldName: fieldName,
|
|
308
|
+
});
|
|
309
|
+
queryConditions.push(_queryConditions);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
const conditionExpr = getQueryConditionExpression(conditionKey);
|
|
314
|
+
if (conditionExpr) {
|
|
315
|
+
const _queryConditions = this.operation__helperFilterBasic({
|
|
316
|
+
fieldName: fieldName,
|
|
317
|
+
val: conditionValue,
|
|
318
|
+
conditionExpr: conditionExpr,
|
|
319
|
+
});
|
|
320
|
+
queryConditions.push(_queryConditions);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
query_validator_1.QueryValidatorCheck.throwQueryNotFound(conditionKey);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
return queryConditions;
|
|
329
|
+
}
|
|
330
|
+
operation_translateBasicQueryOperation({ fieldName, queryObject }) {
|
|
331
|
+
const _queryConditions = this.operation__helperFilterBasic({
|
|
332
|
+
fieldName: fieldName,
|
|
333
|
+
val: queryObject,
|
|
334
|
+
});
|
|
335
|
+
return _queryConditions;
|
|
336
|
+
}
|
|
337
|
+
processQueryFilter({ queryDefs }) {
|
|
338
|
+
let queryMainConditions = [];
|
|
339
|
+
let queryAndConditions = [];
|
|
340
|
+
let queryOrConditions = [];
|
|
341
|
+
Object.keys(queryDefs).forEach((fieldName_Or_And) => {
|
|
342
|
+
if (fieldName_Or_And === "$or") {
|
|
343
|
+
const orKey = fieldName_Or_And;
|
|
344
|
+
const orArray = queryDefs[orKey];
|
|
345
|
+
query_validator_1.QueryValidatorCheck.or_query(orArray);
|
|
346
|
+
if (orArray && Array.isArray(orArray)) {
|
|
347
|
+
orArray.forEach((orQuery) => {
|
|
348
|
+
Object.keys(orQuery).forEach((fieldName) => {
|
|
349
|
+
const orQueryObjectOrValue = orQuery[fieldName];
|
|
350
|
+
if (orQueryObjectOrValue !== undefined) {
|
|
351
|
+
if (orQueryObjectOrValue && typeof orQueryObjectOrValue === "object") {
|
|
352
|
+
const _orQueryCond = this.operation__translateAdvancedQueryOperation({
|
|
353
|
+
fieldName,
|
|
354
|
+
queryObject: orQueryObjectOrValue,
|
|
355
|
+
});
|
|
356
|
+
queryOrConditions = [...queryOrConditions, ..._orQueryCond];
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
const _orQueryConditions = this.operation_translateBasicQueryOperation({
|
|
360
|
+
fieldName,
|
|
361
|
+
queryObject: orQueryObjectOrValue,
|
|
362
|
+
});
|
|
363
|
+
queryOrConditions = [...queryOrConditions, _orQueryConditions];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else if (fieldName_Or_And === "$and") {
|
|
371
|
+
const andKey = fieldName_Or_And;
|
|
372
|
+
const andArray = queryDefs[andKey];
|
|
373
|
+
query_validator_1.QueryValidatorCheck.and_query(andArray);
|
|
374
|
+
if (andArray && Array.isArray(andArray)) {
|
|
375
|
+
andArray.forEach((andQuery) => {
|
|
376
|
+
Object.keys(andQuery).forEach((fieldName) => {
|
|
377
|
+
const andQueryObjectOrValue = andQuery[fieldName];
|
|
378
|
+
if (andQueryObjectOrValue !== undefined) {
|
|
379
|
+
if (andQueryObjectOrValue && typeof andQueryObjectOrValue === "object") {
|
|
380
|
+
const _andQueryCond = this.operation__translateAdvancedQueryOperation({
|
|
381
|
+
fieldName,
|
|
382
|
+
queryObject: andQueryObjectOrValue,
|
|
383
|
+
});
|
|
384
|
+
queryAndConditions = [...queryAndConditions, ..._andQueryCond];
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
const _andQueryConditions = this.operation_translateBasicQueryOperation({
|
|
388
|
+
fieldName,
|
|
389
|
+
queryObject: andQueryObjectOrValue,
|
|
390
|
+
});
|
|
391
|
+
queryAndConditions = [...queryAndConditions, _andQueryConditions];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
if (fieldName_Or_And) {
|
|
400
|
+
const fieldName2 = fieldName_Or_And;
|
|
401
|
+
const queryObjectOrValue = queryDefs[fieldName2];
|
|
402
|
+
if (queryObjectOrValue !== undefined) {
|
|
403
|
+
if (queryObjectOrValue && typeof queryObjectOrValue === "object") {
|
|
404
|
+
const _queryCond = this.operation__translateAdvancedQueryOperation({
|
|
405
|
+
fieldName: fieldName2,
|
|
406
|
+
queryObject: queryObjectOrValue,
|
|
407
|
+
});
|
|
408
|
+
queryMainConditions = [...queryMainConditions, ..._queryCond];
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
const _queryConditions = this.operation_translateBasicQueryOperation({
|
|
412
|
+
fieldName: fieldName2,
|
|
413
|
+
queryObject: queryObjectOrValue,
|
|
414
|
+
});
|
|
415
|
+
queryMainConditions = [...queryMainConditions, _queryConditions];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
let queryAllConditions = {};
|
|
422
|
+
if (queryMainConditions?.length) {
|
|
423
|
+
queryMainConditions.forEach((item1) => {
|
|
424
|
+
if (item1) {
|
|
425
|
+
queryAllConditions = { ...queryAllConditions, ...item1 };
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
if (queryAndConditions?.length) {
|
|
430
|
+
queryAllConditions.$and = queryAndConditions;
|
|
431
|
+
}
|
|
432
|
+
if (queryOrConditions?.length) {
|
|
433
|
+
queryAllConditions.$or = queryOrConditions;
|
|
434
|
+
}
|
|
435
|
+
return queryAllConditions;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
exports.PouchFilterQueryOperation = PouchFilterQueryOperation;
|
|
439
|
+
//# sourceMappingURL=pouch-filter-query-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pouch-filter-query-operation.js","sourceRoot":"","sources":["../../src/pouch/pouch-filter-query-operation.ts"],"names":[],"mappings":";;;AAAA,8CAA4D;AAC5D,gEAAiE;AAoBjE,MAAM,iBAAiB,GAA4C;IACjE,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,EAAE;CAChB,CAAC;AAEF,MAAM,wBAAwB,GAAqF;IACjH,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,SAAS,EAAE,EAAE;IACb,YAAY,EAAE,EAAE;IAChB,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,wBAAwB,GAAG,EAAE,GAAG,iBAAiB,EAAE,GAAG,wBAAwB,EAAE,CAAC;AAOvF,SAAS,oBAAoB,CAAC,GAAW;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,2BAA2B,CAAC,GAAW;IAC9C,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CA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;SAC9C;QAED,IAAI,iBAAiB,EAAE,MAAM,EAAE;YAC7B,kBAAkB,CAAC,GAAG,GAAG,iBAAiB,CAAC;SAC5C;QACD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;CACF;AAvcD,8DAucC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/// <reference types="pouchdb-core" />
|
|
2
|
+
/// <reference types="pouchdb-find" />
|
|
3
|
+
/// <reference types="pouchdb-mapreduce" />
|
|
4
|
+
/// <reference types="pouchdb-replication" />
|
|
5
|
+
import Nano from "nano";
|
|
6
|
+
import type { IMocodyCoreEntityModel } from "../core/base-schema";
|
|
7
|
+
type IFindOptions = {
|
|
8
|
+
databaseName: string;
|
|
9
|
+
featureEntity: string;
|
|
10
|
+
skip: number | undefined;
|
|
11
|
+
limit: number | undefined;
|
|
12
|
+
selector: Nano.MangoSelector;
|
|
13
|
+
fields: string[] | undefined;
|
|
14
|
+
use_index: string;
|
|
15
|
+
sort?: {
|
|
16
|
+
[propName: string]: "asc" | "desc";
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
type IBaseDef<T> = Omit<T & IMocodyCoreEntityModel, "">;
|
|
20
|
+
type ILocalFirstConfig = {
|
|
21
|
+
configType: "LOCAL_FIRST";
|
|
22
|
+
sqliteDbFilePath: string;
|
|
23
|
+
couchDbSyncUri?: string;
|
|
24
|
+
liveSync?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type IRemoteFirstConfig = {
|
|
27
|
+
configType: "REMOTE_FIRST";
|
|
28
|
+
couchDbUri: string;
|
|
29
|
+
};
|
|
30
|
+
interface IOptions {
|
|
31
|
+
pouchConfig: ILocalFirstConfig | IRemoteFirstConfig;
|
|
32
|
+
}
|
|
33
|
+
export declare class MocodyInitializerPouch {
|
|
34
|
+
private _databaseInstance;
|
|
35
|
+
private _pouchInstance;
|
|
36
|
+
private _documentScope;
|
|
37
|
+
private readonly pouchConfig;
|
|
38
|
+
constructor({ pouchConfig }: IOptions);
|
|
39
|
+
deleteIndex({ databaseName, ddoc, name }: {
|
|
40
|
+
databaseName: string;
|
|
41
|
+
ddoc: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
ok: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
getIndexes(databaseName: string): Promise<{
|
|
47
|
+
indexes: {
|
|
48
|
+
ddoc: string;
|
|
49
|
+
name: string;
|
|
50
|
+
type: string;
|
|
51
|
+
def: {
|
|
52
|
+
fields: {
|
|
53
|
+
[field: string]: "asc" | "desc";
|
|
54
|
+
}[];
|
|
55
|
+
};
|
|
56
|
+
}[];
|
|
57
|
+
total_rows: number;
|
|
58
|
+
}>;
|
|
59
|
+
getDocInstance<T>(databaseName: string): Promise<Nano.DocumentScope<IBaseDef<T>>>;
|
|
60
|
+
createDatabase(databaseName: string): Promise<Nano.DatabaseCreateResponse | undefined>;
|
|
61
|
+
getById({ databaseName, nativeId }: {
|
|
62
|
+
databaseName: string;
|
|
63
|
+
nativeId: string;
|
|
64
|
+
}): Promise<(IBaseDef<unknown> & PouchDB.Core.IdMeta & PouchDB.Core.GetMeta) | (Nano.DocumentGetResponse & IBaseDef<unknown>)>;
|
|
65
|
+
private pouch_getById;
|
|
66
|
+
getManyByIds({ databaseName, nativeIds }: {
|
|
67
|
+
databaseName: string;
|
|
68
|
+
nativeIds: string[];
|
|
69
|
+
}): Promise<PouchDB.Core.AllDocsResponse<IBaseDef<unknown>> | Nano.DocumentListResponse<IBaseDef<unknown>>>;
|
|
70
|
+
private pouch_getManyByIds;
|
|
71
|
+
createDoc({ databaseName, validatedData }: {
|
|
72
|
+
databaseName: string;
|
|
73
|
+
validatedData: any;
|
|
74
|
+
}): Promise<Nano.DocumentInsertResponse>;
|
|
75
|
+
private pouch_createDoc;
|
|
76
|
+
updateDoc({ databaseName, docRev, validatedData, }: {
|
|
77
|
+
databaseName: string;
|
|
78
|
+
docRev: string;
|
|
79
|
+
validatedData: any;
|
|
80
|
+
}): Promise<Nano.DocumentInsertResponse>;
|
|
81
|
+
private pouch_updateDoc;
|
|
82
|
+
getList({ databaseName, featureEntity, size, skip, }: {
|
|
83
|
+
databaseName: string;
|
|
84
|
+
featureEntity: string;
|
|
85
|
+
size?: number | null;
|
|
86
|
+
skip?: number | null;
|
|
87
|
+
}): Promise<PouchDB.Core.AllDocsResponse<IBaseDef<unknown>> | Nano.DocumentListResponse<IBaseDef<unknown>>>;
|
|
88
|
+
private pouch_getList;
|
|
89
|
+
findPartitionedDocs({ featureEntity, databaseName, selector, fields, use_index, sort, limit, skip, }: IFindOptions): Promise<PouchDB.Find.FindResponse<IBaseDef<unknown>>>;
|
|
90
|
+
private pouch_findPartitionedDocs;
|
|
91
|
+
deleteById({ databaseName, docRev, nativeId }: {
|
|
92
|
+
databaseName: string;
|
|
93
|
+
docRev: string;
|
|
94
|
+
nativeId: string;
|
|
95
|
+
}): Promise<Nano.DocumentDestroyResponse>;
|
|
96
|
+
getInstance(): Promise<Nano.ServerScope>;
|
|
97
|
+
private getInstanceBase;
|
|
98
|
+
pouch_getDbInstance(): Promise<PouchDB.Database<IBaseDef<unknown>>>;
|
|
99
|
+
private isLocalFirst;
|
|
100
|
+
private pouch_getDbInstanceBase;
|
|
101
|
+
}
|
|
102
|
+
export {};
|