@cloudbase/database 0.9.19 → 0.9.20
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/.trunk/configs/.markdownlint.yaml +10 -0
- package/.trunk/trunk.yaml +26 -0
- package/dist/commonjs/aggregate.d.ts +29 -29
- package/dist/commonjs/aggregate.js +156 -156
- package/dist/commonjs/collection.d.ts +9 -9
- package/dist/commonjs/collection.js +46 -46
- package/dist/commonjs/command.d.ts +175 -175
- package/dist/commonjs/command.js +298 -298
- package/dist/commonjs/commands/logic.d.ts +24 -24
- package/dist/commonjs/commands/logic.js +88 -88
- package/dist/commonjs/commands/query.d.ts +68 -68
- package/dist/commonjs/commands/query.js +157 -157
- package/dist/commonjs/commands/update.d.ts +29 -29
- package/dist/commonjs/commands/update.js +50 -50
- package/dist/commonjs/config/app.config.d.ts +6 -6
- package/dist/commonjs/config/app.config.js +7 -7
- package/dist/commonjs/config/error.config.d.ts +3 -3
- package/dist/commonjs/config/error.config.js +15 -15
- package/dist/commonjs/const/code.d.ts +30 -30
- package/dist/commonjs/const/code.js +32 -32
- package/dist/commonjs/constant.d.ts +51 -51
- package/dist/commonjs/constant.js +74 -74
- package/dist/commonjs/document.d.ts +11 -11
- package/dist/commonjs/document.js +249 -252
- package/dist/commonjs/geo/index.d.ts +6 -6
- package/dist/commonjs/geo/index.js +11 -11
- package/dist/commonjs/geo/interface.d.ts +24 -24
- package/dist/commonjs/geo/interface.js +2 -2
- package/dist/commonjs/geo/lineString.d.ts +19 -19
- package/dist/commonjs/geo/lineString.js +85 -85
- package/dist/commonjs/geo/multiLineString.d.ts +18 -18
- package/dist/commonjs/geo/multiLineString.js +94 -94
- package/dist/commonjs/geo/multiPoint.d.ts +18 -18
- package/dist/commonjs/geo/multiPoint.js +78 -78
- package/dist/commonjs/geo/multiPolygon.d.ts +18 -18
- package/dist/commonjs/geo/multiPolygon.js +121 -121
- package/dist/commonjs/geo/point.d.ts +19 -19
- package/dist/commonjs/geo/point.js +49 -49
- package/dist/commonjs/geo/polygon.d.ts +19 -19
- package/dist/commonjs/geo/polygon.js +108 -108
- package/dist/commonjs/helper/symbol.d.ts +14 -14
- package/dist/commonjs/helper/symbol.js +19 -19
- package/dist/commonjs/index.d.ts +33 -33
- package/dist/commonjs/index.js +46 -46
- package/dist/commonjs/lib/util.d.ts +1 -1
- package/dist/commonjs/lib/util.js +25 -25
- package/dist/commonjs/operator-map.d.ts +4 -4
- package/dist/commonjs/operator-map.js +23 -23
- package/dist/commonjs/query.d.ts +22 -22
- package/dist/commonjs/query.js +251 -251
- package/dist/commonjs/regexp/index.d.ts +14 -14
- package/dist/commonjs/regexp/index.js +32 -32
- package/dist/commonjs/serializer/common.d.ts +11 -11
- package/dist/commonjs/serializer/common.js +121 -121
- package/dist/commonjs/serializer/datatype.d.ts +7 -7
- package/dist/commonjs/serializer/datatype.js +126 -126
- package/dist/commonjs/serializer/query.d.ts +7 -7
- package/dist/commonjs/serializer/query.js +231 -231
- package/dist/commonjs/serializer/update.d.ts +15 -15
- package/dist/commonjs/serializer/update.js +141 -141
- package/dist/commonjs/serverDate/index.d.ts +13 -13
- package/dist/commonjs/serverDate/index.js +29 -29
- package/dist/commonjs/transaction/collection.d.ts +7 -7
- package/dist/commonjs/transaction/collection.js +46 -46
- package/dist/commonjs/transaction/document.d.ts +27 -27
- package/dist/commonjs/transaction/document.js +205 -205
- package/dist/commonjs/transaction/index.d.ts +30 -30
- package/dist/commonjs/transaction/index.js +214 -214
- package/dist/commonjs/transaction/query.d.ts +5 -5
- package/dist/commonjs/transaction/query.js +10 -10
- package/dist/commonjs/typings/index.d.ts +40 -40
- package/dist/commonjs/typings/index.js +2 -2
- package/dist/commonjs/typings/realtime.d.ts +219 -219
- package/dist/commonjs/typings/realtime.js +2 -2
- package/dist/commonjs/util.d.ts +9 -9
- package/dist/commonjs/util.js +144 -144
- package/dist/commonjs/utils/error.d.ts +37 -37
- package/dist/commonjs/utils/error.js +85 -85
- package/dist/commonjs/utils/symbol.d.ts +8 -8
- package/dist/commonjs/utils/symbol.js +57 -57
- package/dist/commonjs/utils/type.d.ts +13 -13
- package/dist/commonjs/utils/type.js +22 -22
- package/dist/commonjs/utils/utils.d.ts +4 -4
- package/dist/commonjs/utils/utils.js +36 -36
- package/dist/commonjs/validate.d.ts +1 -1
- package/dist/commonjs/validate.js +59 -59
- package/package.json +2 -3
- package/src/document.ts +1 -4
- package/src/query.ts +3 -3
- package/dist/commonjs/ObjectId/index.d.ts +0 -11
- package/dist/commonjs/ObjectId/index.js +0 -21
- package/dist/commonjs/realtime/error.d.ts +0 -7
- package/dist/commonjs/realtime/error.js +0 -11
- package/dist/commonjs/realtime/listener.d.ts +0 -14
- package/dist/commonjs/realtime/listener.js +0 -17
- package/dist/commonjs/realtime/message.d.ts +0 -3
- package/dist/commonjs/realtime/message.js +0 -10
- package/dist/commonjs/realtime/snapshot.d.ts +0 -16
- package/dist/commonjs/realtime/snapshot.js +0 -42
- package/dist/commonjs/realtime/virtual-websocket-client.d.ts +0 -63
- package/dist/commonjs/realtime/virtual-websocket-client.js +0 -736
- package/dist/commonjs/realtime/websocket-client.d.ts +0 -78
- package/dist/commonjs/realtime/websocket-client.js +0 -567
- package/dist/commonjs/realtime/ws-event.d.ts +0 -126
- package/dist/commonjs/realtime/ws-event.js +0 -139
- package/dist/commonjs/transaction.d.ts +0 -42
- package/dist/commonjs/transaction.js +0 -126
- package/dist/esm/ObjectId/index.d.ts +0 -11
- package/dist/esm/ObjectId/index.js +0 -17
- package/dist/esm/aggregate.d.ts +0 -29
- package/dist/esm/aggregate.js +0 -154
- package/dist/esm/collection.d.ts +0 -9
- package/dist/esm/collection.js +0 -44
- package/dist/esm/command.d.ts +0 -175
- package/dist/esm/command.js +0 -296
- package/dist/esm/commands/logic.d.ts +0 -24
- package/dist/esm/commands/logic.js +0 -84
- package/dist/esm/commands/query.d.ts +0 -68
- package/dist/esm/commands/query.js +0 -152
- package/dist/esm/commands/update.d.ts +0 -29
- package/dist/esm/commands/update.js +0 -46
- package/dist/esm/config/app.config.d.ts +0 -6
- package/dist/esm/config/app.config.js +0 -5
- package/dist/esm/config/error.config.d.ts +0 -3
- package/dist/esm/config/error.config.js +0 -13
- package/dist/esm/const/code.d.ts +0 -30
- package/dist/esm/const/code.js +0 -30
- package/dist/esm/constant.d.ts +0 -51
- package/dist/esm/constant.js +0 -65
- package/dist/esm/document.d.ts +0 -11
- package/dist/esm/document.js +0 -250
- package/dist/esm/geo/index.d.ts +0 -6
- package/dist/esm/geo/index.js +0 -6
- package/dist/esm/geo/interface.d.ts +0 -24
- package/dist/esm/geo/interface.js +0 -0
- package/dist/esm/geo/lineString.d.ts +0 -19
- package/dist/esm/geo/lineString.js +0 -83
- package/dist/esm/geo/multiLineString.d.ts +0 -18
- package/dist/esm/geo/multiLineString.js +0 -92
- package/dist/esm/geo/multiPoint.d.ts +0 -18
- package/dist/esm/geo/multiPoint.js +0 -76
- package/dist/esm/geo/multiPolygon.d.ts +0 -18
- package/dist/esm/geo/multiPolygon.js +0 -119
- package/dist/esm/geo/point.d.ts +0 -19
- package/dist/esm/geo/point.js +0 -47
- package/dist/esm/geo/polygon.d.ts +0 -19
- package/dist/esm/geo/polygon.js +0 -106
- package/dist/esm/helper/symbol.d.ts +0 -14
- package/dist/esm/helper/symbol.js +0 -14
- package/dist/esm/index.d.ts +0 -33
- package/dist/esm/index.js +0 -41
- package/dist/esm/lib/util.d.ts +0 -1
- package/dist/esm/lib/util.js +0 -23
- package/dist/esm/operator-map.d.ts +0 -4
- package/dist/esm/operator-map.js +0 -20
- package/dist/esm/query.d.ts +0 -22
- package/dist/esm/query.js +0 -249
- package/dist/esm/realtime/error.d.ts +0 -7
- package/dist/esm/realtime/error.js +0 -8
- package/dist/esm/realtime/listener.d.ts +0 -14
- package/dist/esm/realtime/listener.js +0 -14
- package/dist/esm/realtime/message.d.ts +0 -3
- package/dist/esm/realtime/message.js +0 -6
- package/dist/esm/realtime/snapshot.d.ts +0 -16
- package/dist/esm/realtime/snapshot.js +0 -39
- package/dist/esm/realtime/virtual-websocket-client.d.ts +0 -63
- package/dist/esm/realtime/virtual-websocket-client.js +0 -733
- package/dist/esm/realtime/websocket-client.d.ts +0 -78
- package/dist/esm/realtime/websocket-client.js +0 -564
- package/dist/esm/realtime/ws-event.d.ts +0 -126
- package/dist/esm/realtime/ws-event.js +0 -137
- package/dist/esm/regexp/index.d.ts +0 -14
- package/dist/esm/regexp/index.js +0 -29
- package/dist/esm/serializer/common.d.ts +0 -11
- package/dist/esm/serializer/common.js +0 -113
- package/dist/esm/serializer/datatype.d.ts +0 -7
- package/dist/esm/serializer/datatype.js +0 -122
- package/dist/esm/serializer/query.d.ts +0 -7
- package/dist/esm/serializer/query.js +0 -229
- package/dist/esm/serializer/update.d.ts +0 -15
- package/dist/esm/serializer/update.js +0 -139
- package/dist/esm/serverDate/index.d.ts +0 -13
- package/dist/esm/serverDate/index.js +0 -26
- package/dist/esm/transaction/collection.d.ts +0 -7
- package/dist/esm/transaction/collection.js +0 -44
- package/dist/esm/transaction/document.d.ts +0 -27
- package/dist/esm/transaction/document.js +0 -203
- package/dist/esm/transaction/index.d.ts +0 -30
- package/dist/esm/transaction/index.js +0 -210
- package/dist/esm/transaction/query.d.ts +0 -5
- package/dist/esm/transaction/query.js +0 -8
- package/dist/esm/transaction.d.ts +0 -42
- package/dist/esm/transaction.js +0 -121
- package/dist/esm/typings/index.d.ts +0 -40
- package/dist/esm/typings/index.js +0 -0
- package/dist/esm/typings/realtime.d.ts +0 -219
- package/dist/esm/typings/realtime.js +0 -0
- package/dist/esm/util.d.ts +0 -9
- package/dist/esm/util.js +0 -142
- package/dist/esm/utils/error.d.ts +0 -37
- package/dist/esm/utils/error.js +0 -82
- package/dist/esm/utils/msg.d.ts +0 -0
- package/dist/esm/utils/msg.js +0 -0
- package/dist/esm/utils/symbol.d.ts +0 -8
- package/dist/esm/utils/symbol.js +0 -55
- package/dist/esm/utils/type.d.ts +0 -13
- package/dist/esm/utils/type.js +0 -20
- package/dist/esm/utils/utils.d.ts +0 -4
- package/dist/esm/utils/utils.js +0 -33
- package/dist/esm/validate.d.ts +0 -1
- package/dist/esm/validate.js +0 -57
package/dist/esm/collection.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
extendStatics(d, b);
|
|
10
|
-
function __() { this.constructor = d; }
|
|
11
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
-
};
|
|
13
|
-
})();
|
|
14
|
-
import { DocumentReference } from './document';
|
|
15
|
-
import { Query } from './query';
|
|
16
|
-
import Aggregation from './aggregate';
|
|
17
|
-
var CollectionReference = (function (_super) {
|
|
18
|
-
__extends(CollectionReference, _super);
|
|
19
|
-
function CollectionReference(db, coll) {
|
|
20
|
-
return _super.call(this, db, coll) || this;
|
|
21
|
-
}
|
|
22
|
-
Object.defineProperty(CollectionReference.prototype, "name", {
|
|
23
|
-
get: function () {
|
|
24
|
-
return this._coll;
|
|
25
|
-
},
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true
|
|
28
|
-
});
|
|
29
|
-
CollectionReference.prototype.doc = function (docID) {
|
|
30
|
-
if (typeof docID !== 'string' && typeof docID !== 'number') {
|
|
31
|
-
throw new Error('docId必须为字符串或数字');
|
|
32
|
-
}
|
|
33
|
-
return new DocumentReference(this._db, this._coll, docID);
|
|
34
|
-
};
|
|
35
|
-
CollectionReference.prototype.add = function (data, callback) {
|
|
36
|
-
var docRef = new DocumentReference(this._db, this._coll, undefined);
|
|
37
|
-
return docRef.create(data, callback);
|
|
38
|
-
};
|
|
39
|
-
CollectionReference.prototype.aggregate = function () {
|
|
40
|
-
return new Aggregation(this._db, this._coll);
|
|
41
|
-
};
|
|
42
|
-
return CollectionReference;
|
|
43
|
-
}(Query));
|
|
44
|
-
export { CollectionReference };
|
package/dist/esm/command.d.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { QueryCommand } from './commands/query';
|
|
2
|
-
import { LogicCommand } from './commands/logic';
|
|
3
|
-
import { UpdateCommand } from './commands/update';
|
|
4
|
-
import Aggregation from './aggregate';
|
|
5
|
-
export declare type IQueryCondition = Record<string, any> | LogicCommand;
|
|
6
|
-
export declare const Command: {
|
|
7
|
-
eq(val: any): QueryCommand;
|
|
8
|
-
neq(val: any): QueryCommand;
|
|
9
|
-
lt(val: any): QueryCommand;
|
|
10
|
-
lte(val: any): QueryCommand;
|
|
11
|
-
gt(val: any): QueryCommand;
|
|
12
|
-
gte(val: any): QueryCommand;
|
|
13
|
-
in(val: any): QueryCommand;
|
|
14
|
-
nin(val: any): QueryCommand;
|
|
15
|
-
all(val: any): QueryCommand;
|
|
16
|
-
elemMatch(val: any): QueryCommand;
|
|
17
|
-
exists(val: boolean): QueryCommand;
|
|
18
|
-
size(val: number): QueryCommand;
|
|
19
|
-
mod(val: number[]): QueryCommand;
|
|
20
|
-
geoNear(val: any): QueryCommand;
|
|
21
|
-
geoWithin(val: any): QueryCommand;
|
|
22
|
-
geoIntersects(val: any): QueryCommand;
|
|
23
|
-
and(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
|
|
24
|
-
nor(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
|
|
25
|
-
or(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
|
|
26
|
-
not(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
|
|
27
|
-
set(val: any): UpdateCommand;
|
|
28
|
-
remove(): UpdateCommand;
|
|
29
|
-
inc(val: number): UpdateCommand;
|
|
30
|
-
mul(val: number): UpdateCommand;
|
|
31
|
-
push(...args: any[]): UpdateCommand;
|
|
32
|
-
pull(values: any): UpdateCommand;
|
|
33
|
-
pullAll(values: any): UpdateCommand;
|
|
34
|
-
pop(): UpdateCommand;
|
|
35
|
-
shift(): UpdateCommand;
|
|
36
|
-
unshift(...__values__: any[]): UpdateCommand;
|
|
37
|
-
addToSet(values: any): UpdateCommand;
|
|
38
|
-
rename(values: any): UpdateCommand;
|
|
39
|
-
bit(values: any): UpdateCommand;
|
|
40
|
-
max(values: any): UpdateCommand;
|
|
41
|
-
min(values: any): UpdateCommand;
|
|
42
|
-
expr(values: AggregationOperator): {
|
|
43
|
-
$expr: AggregationOperator;
|
|
44
|
-
};
|
|
45
|
-
jsonSchema(schema: any): {
|
|
46
|
-
$jsonSchema: any;
|
|
47
|
-
};
|
|
48
|
-
text(values: string | {
|
|
49
|
-
search: string;
|
|
50
|
-
language?: string;
|
|
51
|
-
caseSensitive?: boolean;
|
|
52
|
-
diacriticSensitive: boolean;
|
|
53
|
-
}): {
|
|
54
|
-
$search: {
|
|
55
|
-
(regexp: string | RegExp): number;
|
|
56
|
-
(searcher: {
|
|
57
|
-
[Symbol.search](string: string): number;
|
|
58
|
-
}): number;
|
|
59
|
-
};
|
|
60
|
-
$language?: undefined;
|
|
61
|
-
$caseSensitive?: undefined;
|
|
62
|
-
$diacriticSensitive?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
$search: string;
|
|
65
|
-
$language: string;
|
|
66
|
-
$caseSensitive: boolean;
|
|
67
|
-
$diacriticSensitive: boolean;
|
|
68
|
-
};
|
|
69
|
-
aggregate: {
|
|
70
|
-
pipeline(): Aggregation;
|
|
71
|
-
abs: (param: any) => AggregationOperator;
|
|
72
|
-
add: (param: any) => AggregationOperator;
|
|
73
|
-
ceil: (param: any) => AggregationOperator;
|
|
74
|
-
divide: (param: any) => AggregationOperator;
|
|
75
|
-
exp: (param: any) => AggregationOperator;
|
|
76
|
-
floor: (param: any) => AggregationOperator;
|
|
77
|
-
ln: (param: any) => AggregationOperator;
|
|
78
|
-
log: (param: any) => AggregationOperator;
|
|
79
|
-
log10: (param: any) => AggregationOperator;
|
|
80
|
-
mod: (param: any) => AggregationOperator;
|
|
81
|
-
multiply: (param: any) => AggregationOperator;
|
|
82
|
-
pow: (param: any) => AggregationOperator;
|
|
83
|
-
sqrt: (param: any) => AggregationOperator;
|
|
84
|
-
subtract: (param: any) => AggregationOperator;
|
|
85
|
-
trunc: (param: any) => AggregationOperator;
|
|
86
|
-
arrayElemAt: (param: any) => AggregationOperator;
|
|
87
|
-
arrayToObject: (param: any) => AggregationOperator;
|
|
88
|
-
concatArrays: (param: any) => AggregationOperator;
|
|
89
|
-
filter: (param: any) => AggregationOperator;
|
|
90
|
-
in: (param: any) => AggregationOperator;
|
|
91
|
-
indexOfArray: (param: any) => AggregationOperator;
|
|
92
|
-
isArray: (param: any) => AggregationOperator;
|
|
93
|
-
map: (param: any) => AggregationOperator;
|
|
94
|
-
range: (param: any) => AggregationOperator;
|
|
95
|
-
reduce: (param: any) => AggregationOperator;
|
|
96
|
-
reverseArray: (param: any) => AggregationOperator;
|
|
97
|
-
size: (param: any) => AggregationOperator;
|
|
98
|
-
slice: (param: any) => AggregationOperator;
|
|
99
|
-
zip: (param: any) => AggregationOperator;
|
|
100
|
-
and: (param: any) => AggregationOperator;
|
|
101
|
-
not: (param: any) => AggregationOperator;
|
|
102
|
-
or: (param: any) => AggregationOperator;
|
|
103
|
-
cmp: (param: any) => AggregationOperator;
|
|
104
|
-
eq: (param: any) => AggregationOperator;
|
|
105
|
-
gt: (param: any) => AggregationOperator;
|
|
106
|
-
gte: (param: any) => AggregationOperator;
|
|
107
|
-
lt: (param: any) => AggregationOperator;
|
|
108
|
-
lte: (param: any) => AggregationOperator;
|
|
109
|
-
neq: (param: any) => AggregationOperator;
|
|
110
|
-
cond: (param: any) => AggregationOperator;
|
|
111
|
-
ifNull: (param: any) => AggregationOperator;
|
|
112
|
-
switch: (param: any) => AggregationOperator;
|
|
113
|
-
dateFromParts: (param: any) => AggregationOperator;
|
|
114
|
-
dateFromString: (param: any) => AggregationOperator;
|
|
115
|
-
dayOfMonth: (param: any) => AggregationOperator;
|
|
116
|
-
dayOfWeek: (param: any) => AggregationOperator;
|
|
117
|
-
dayOfYear: (param: any) => AggregationOperator;
|
|
118
|
-
isoDayOfWeek: (param: any) => AggregationOperator;
|
|
119
|
-
isoWeek: (param: any) => AggregationOperator;
|
|
120
|
-
isoWeekYear: (param: any) => AggregationOperator;
|
|
121
|
-
millisecond: (param: any) => AggregationOperator;
|
|
122
|
-
minute: (param: any) => AggregationOperator;
|
|
123
|
-
month: (param: any) => AggregationOperator;
|
|
124
|
-
second: (param: any) => AggregationOperator;
|
|
125
|
-
hour: (param: any) => AggregationOperator;
|
|
126
|
-
week: (param: any) => AggregationOperator;
|
|
127
|
-
year: (param: any) => AggregationOperator;
|
|
128
|
-
literal: (param: any) => AggregationOperator;
|
|
129
|
-
mergeObjects: (param: any) => AggregationOperator;
|
|
130
|
-
objectToArray: (param: any) => AggregationOperator;
|
|
131
|
-
allElementsTrue: (param: any) => AggregationOperator;
|
|
132
|
-
anyElementTrue: (param: any) => AggregationOperator;
|
|
133
|
-
setDifference: (param: any) => AggregationOperator;
|
|
134
|
-
setEquals: (param: any) => AggregationOperator;
|
|
135
|
-
setIntersection: (param: any) => AggregationOperator;
|
|
136
|
-
setIsSubset: (param: any) => AggregationOperator;
|
|
137
|
-
setUnion: (param: any) => AggregationOperator;
|
|
138
|
-
concat: (param: any) => AggregationOperator;
|
|
139
|
-
dateToString: (param: any) => AggregationOperator;
|
|
140
|
-
indexOfBytes: (param: any) => AggregationOperator;
|
|
141
|
-
indexOfCP: (param: any) => AggregationOperator;
|
|
142
|
-
split: (param: any) => AggregationOperator;
|
|
143
|
-
strLenBytes: (param: any) => AggregationOperator;
|
|
144
|
-
strLenCP: (param: any) => AggregationOperator;
|
|
145
|
-
strcasecmp: (param: any) => AggregationOperator;
|
|
146
|
-
substr: (param: any) => AggregationOperator;
|
|
147
|
-
substrBytes: (param: any) => AggregationOperator;
|
|
148
|
-
substrCP: (param: any) => AggregationOperator;
|
|
149
|
-
toLower: (param: any) => AggregationOperator;
|
|
150
|
-
toUpper: (param: any) => AggregationOperator;
|
|
151
|
-
meta: (param: any) => AggregationOperator;
|
|
152
|
-
addToSet: (param: any) => AggregationOperator;
|
|
153
|
-
avg: (param: any) => AggregationOperator;
|
|
154
|
-
first: (param: any) => AggregationOperator;
|
|
155
|
-
last: (param: any) => AggregationOperator;
|
|
156
|
-
max: (param: any) => AggregationOperator;
|
|
157
|
-
min: (param: any) => AggregationOperator;
|
|
158
|
-
push: (param: any) => AggregationOperator;
|
|
159
|
-
stdDevPop: (param: any) => AggregationOperator;
|
|
160
|
-
stdDevSamp: (param: any) => AggregationOperator;
|
|
161
|
-
sum: (param: any) => AggregationOperator;
|
|
162
|
-
let: (param: any) => AggregationOperator;
|
|
163
|
-
};
|
|
164
|
-
project: {
|
|
165
|
-
slice: (param: any) => ProjectionOperator;
|
|
166
|
-
elemMatch: (param: any) => ProjectionOperator;
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
declare class AggregationOperator {
|
|
170
|
-
constructor(name: any, param: any);
|
|
171
|
-
}
|
|
172
|
-
declare class ProjectionOperator {
|
|
173
|
-
constructor(name: any, param: any);
|
|
174
|
-
}
|
|
175
|
-
export default Command;
|
package/dist/esm/command.js
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { QueryCommand, QUERY_COMMANDS_LITERAL } from './commands/query';
|
|
2
|
-
import { LogicCommand, LOGIC_COMMANDS_LITERAL } from './commands/logic';
|
|
3
|
-
import { UpdateCommand, UPDATE_COMMANDS_LITERAL } from './commands/update';
|
|
4
|
-
import { isArray, isObject, isString } from './utils/type';
|
|
5
|
-
import Aggregation from './aggregate';
|
|
6
|
-
export var Command = {
|
|
7
|
-
eq: function (val) {
|
|
8
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.EQ, [val]);
|
|
9
|
-
},
|
|
10
|
-
neq: function (val) {
|
|
11
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.NEQ, [val]);
|
|
12
|
-
},
|
|
13
|
-
lt: function (val) {
|
|
14
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.LT, [val]);
|
|
15
|
-
},
|
|
16
|
-
lte: function (val) {
|
|
17
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.LTE, [val]);
|
|
18
|
-
},
|
|
19
|
-
gt: function (val) {
|
|
20
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.GT, [val]);
|
|
21
|
-
},
|
|
22
|
-
gte: function (val) {
|
|
23
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.GTE, [val]);
|
|
24
|
-
},
|
|
25
|
-
in: function (val) {
|
|
26
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.IN, val);
|
|
27
|
-
},
|
|
28
|
-
nin: function (val) {
|
|
29
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.NIN, val);
|
|
30
|
-
},
|
|
31
|
-
all: function (val) {
|
|
32
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.ALL, val);
|
|
33
|
-
},
|
|
34
|
-
elemMatch: function (val) {
|
|
35
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.ELEM_MATCH, [val]);
|
|
36
|
-
},
|
|
37
|
-
exists: function (val) {
|
|
38
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.EXISTS, [val]);
|
|
39
|
-
},
|
|
40
|
-
size: function (val) {
|
|
41
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.SIZE, [val]);
|
|
42
|
-
},
|
|
43
|
-
mod: function (val) {
|
|
44
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.MOD, [val]);
|
|
45
|
-
},
|
|
46
|
-
geoNear: function (val) {
|
|
47
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_NEAR, [val]);
|
|
48
|
-
},
|
|
49
|
-
geoWithin: function (val) {
|
|
50
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_WITHIN, [val]);
|
|
51
|
-
},
|
|
52
|
-
geoIntersects: function (val) {
|
|
53
|
-
return new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_INTERSECTS, [val]);
|
|
54
|
-
},
|
|
55
|
-
and: function () {
|
|
56
|
-
var __expressions__ = [];
|
|
57
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
58
|
-
__expressions__[_i] = arguments[_i];
|
|
59
|
-
}
|
|
60
|
-
var expressions = isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
61
|
-
return new LogicCommand(LOGIC_COMMANDS_LITERAL.AND, expressions);
|
|
62
|
-
},
|
|
63
|
-
nor: function () {
|
|
64
|
-
var __expressions__ = [];
|
|
65
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
66
|
-
__expressions__[_i] = arguments[_i];
|
|
67
|
-
}
|
|
68
|
-
var expressions = isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
69
|
-
return new LogicCommand(LOGIC_COMMANDS_LITERAL.NOR, expressions);
|
|
70
|
-
},
|
|
71
|
-
or: function () {
|
|
72
|
-
var __expressions__ = [];
|
|
73
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
74
|
-
__expressions__[_i] = arguments[_i];
|
|
75
|
-
}
|
|
76
|
-
var expressions = isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
77
|
-
return new LogicCommand(LOGIC_COMMANDS_LITERAL.OR, expressions);
|
|
78
|
-
},
|
|
79
|
-
not: function () {
|
|
80
|
-
var __expressions__ = [];
|
|
81
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
82
|
-
__expressions__[_i] = arguments[_i];
|
|
83
|
-
}
|
|
84
|
-
var expressions = isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
85
|
-
return new LogicCommand(LOGIC_COMMANDS_LITERAL.NOT, expressions);
|
|
86
|
-
},
|
|
87
|
-
set: function (val) {
|
|
88
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.SET, [val]);
|
|
89
|
-
},
|
|
90
|
-
remove: function () {
|
|
91
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.REMOVE, []);
|
|
92
|
-
},
|
|
93
|
-
inc: function (val) {
|
|
94
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.INC, [val]);
|
|
95
|
-
},
|
|
96
|
-
mul: function (val) {
|
|
97
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.MUL, [val]);
|
|
98
|
-
},
|
|
99
|
-
push: function () {
|
|
100
|
-
var args = [];
|
|
101
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
102
|
-
args[_i] = arguments[_i];
|
|
103
|
-
}
|
|
104
|
-
var values;
|
|
105
|
-
if (isObject(args[0]) && args[0].hasOwnProperty('each')) {
|
|
106
|
-
var options = args[0];
|
|
107
|
-
values = {
|
|
108
|
-
$each: options.each,
|
|
109
|
-
$position: options.position,
|
|
110
|
-
$sort: options.sort,
|
|
111
|
-
$slice: options.slice
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
else if (isArray(args[0])) {
|
|
115
|
-
values = args[0];
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
values = Array.from(args);
|
|
119
|
-
}
|
|
120
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.PUSH, values);
|
|
121
|
-
},
|
|
122
|
-
pull: function (values) {
|
|
123
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.PULL, values);
|
|
124
|
-
},
|
|
125
|
-
pullAll: function (values) {
|
|
126
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.PULL_ALL, values);
|
|
127
|
-
},
|
|
128
|
-
pop: function () {
|
|
129
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.POP, []);
|
|
130
|
-
},
|
|
131
|
-
shift: function () {
|
|
132
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.SHIFT, []);
|
|
133
|
-
},
|
|
134
|
-
unshift: function () {
|
|
135
|
-
var __values__ = [];
|
|
136
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
137
|
-
__values__[_i] = arguments[_i];
|
|
138
|
-
}
|
|
139
|
-
var values = isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
140
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.UNSHIFT, values);
|
|
141
|
-
},
|
|
142
|
-
addToSet: function (values) {
|
|
143
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.ADD_TO_SET, values);
|
|
144
|
-
},
|
|
145
|
-
rename: function (values) {
|
|
146
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.RENAME, [values]);
|
|
147
|
-
},
|
|
148
|
-
bit: function (values) {
|
|
149
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.BIT, [values]);
|
|
150
|
-
},
|
|
151
|
-
max: function (values) {
|
|
152
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.MAX, [values]);
|
|
153
|
-
},
|
|
154
|
-
min: function (values) {
|
|
155
|
-
return new UpdateCommand(UPDATE_COMMANDS_LITERAL.MIN, [values]);
|
|
156
|
-
},
|
|
157
|
-
expr: function (values) {
|
|
158
|
-
return {
|
|
159
|
-
$expr: values
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
jsonSchema: function (schema) {
|
|
163
|
-
return {
|
|
164
|
-
$jsonSchema: schema
|
|
165
|
-
};
|
|
166
|
-
},
|
|
167
|
-
text: function (values) {
|
|
168
|
-
if (isString(values)) {
|
|
169
|
-
return {
|
|
170
|
-
$search: values.search
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
return {
|
|
175
|
-
$search: values.search,
|
|
176
|
-
$language: values.language,
|
|
177
|
-
$caseSensitive: values.caseSensitive,
|
|
178
|
-
$diacriticSensitive: values.diacriticSensitive
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
aggregate: {
|
|
183
|
-
pipeline: function () {
|
|
184
|
-
return new Aggregation();
|
|
185
|
-
},
|
|
186
|
-
abs: function (param) { return new AggregationOperator('abs', param); },
|
|
187
|
-
add: function (param) { return new AggregationOperator('add', param); },
|
|
188
|
-
ceil: function (param) { return new AggregationOperator('ceil', param); },
|
|
189
|
-
divide: function (param) { return new AggregationOperator('divide', param); },
|
|
190
|
-
exp: function (param) { return new AggregationOperator('exp', param); },
|
|
191
|
-
floor: function (param) { return new AggregationOperator('floor', param); },
|
|
192
|
-
ln: function (param) { return new AggregationOperator('ln', param); },
|
|
193
|
-
log: function (param) { return new AggregationOperator('log', param); },
|
|
194
|
-
log10: function (param) { return new AggregationOperator('log10', param); },
|
|
195
|
-
mod: function (param) { return new AggregationOperator('mod', param); },
|
|
196
|
-
multiply: function (param) { return new AggregationOperator('multiply', param); },
|
|
197
|
-
pow: function (param) { return new AggregationOperator('pow', param); },
|
|
198
|
-
sqrt: function (param) { return new AggregationOperator('sqrt', param); },
|
|
199
|
-
subtract: function (param) { return new AggregationOperator('subtract', param); },
|
|
200
|
-
trunc: function (param) { return new AggregationOperator('trunc', param); },
|
|
201
|
-
arrayElemAt: function (param) { return new AggregationOperator('arrayElemAt', param); },
|
|
202
|
-
arrayToObject: function (param) { return new AggregationOperator('arrayToObject', param); },
|
|
203
|
-
concatArrays: function (param) { return new AggregationOperator('concatArrays', param); },
|
|
204
|
-
filter: function (param) { return new AggregationOperator('filter', param); },
|
|
205
|
-
in: function (param) { return new AggregationOperator('in', param); },
|
|
206
|
-
indexOfArray: function (param) { return new AggregationOperator('indexOfArray', param); },
|
|
207
|
-
isArray: function (param) { return new AggregationOperator('isArray', param); },
|
|
208
|
-
map: function (param) { return new AggregationOperator('map', param); },
|
|
209
|
-
range: function (param) { return new AggregationOperator('range', param); },
|
|
210
|
-
reduce: function (param) { return new AggregationOperator('reduce', param); },
|
|
211
|
-
reverseArray: function (param) { return new AggregationOperator('reverseArray', param); },
|
|
212
|
-
size: function (param) { return new AggregationOperator('size', param); },
|
|
213
|
-
slice: function (param) { return new AggregationOperator('slice', param); },
|
|
214
|
-
zip: function (param) { return new AggregationOperator('zip', param); },
|
|
215
|
-
and: function (param) { return new AggregationOperator('and', param); },
|
|
216
|
-
not: function (param) { return new AggregationOperator('not', param); },
|
|
217
|
-
or: function (param) { return new AggregationOperator('or', param); },
|
|
218
|
-
cmp: function (param) { return new AggregationOperator('cmp', param); },
|
|
219
|
-
eq: function (param) { return new AggregationOperator('eq', param); },
|
|
220
|
-
gt: function (param) { return new AggregationOperator('gt', param); },
|
|
221
|
-
gte: function (param) { return new AggregationOperator('gte', param); },
|
|
222
|
-
lt: function (param) { return new AggregationOperator('lt', param); },
|
|
223
|
-
lte: function (param) { return new AggregationOperator('lte', param); },
|
|
224
|
-
neq: function (param) { return new AggregationOperator('ne', param); },
|
|
225
|
-
cond: function (param) { return new AggregationOperator('cond', param); },
|
|
226
|
-
ifNull: function (param) { return new AggregationOperator('ifNull', param); },
|
|
227
|
-
switch: function (param) { return new AggregationOperator('switch', param); },
|
|
228
|
-
dateFromParts: function (param) { return new AggregationOperator('dateFromParts', param); },
|
|
229
|
-
dateFromString: function (param) { return new AggregationOperator('dateFromString', param); },
|
|
230
|
-
dayOfMonth: function (param) { return new AggregationOperator('dayOfMonth', param); },
|
|
231
|
-
dayOfWeek: function (param) { return new AggregationOperator('dayOfWeek', param); },
|
|
232
|
-
dayOfYear: function (param) { return new AggregationOperator('dayOfYear', param); },
|
|
233
|
-
isoDayOfWeek: function (param) { return new AggregationOperator('isoDayOfWeek', param); },
|
|
234
|
-
isoWeek: function (param) { return new AggregationOperator('isoWeek', param); },
|
|
235
|
-
isoWeekYear: function (param) { return new AggregationOperator('isoWeekYear', param); },
|
|
236
|
-
millisecond: function (param) { return new AggregationOperator('millisecond', param); },
|
|
237
|
-
minute: function (param) { return new AggregationOperator('minute', param); },
|
|
238
|
-
month: function (param) { return new AggregationOperator('month', param); },
|
|
239
|
-
second: function (param) { return new AggregationOperator('second', param); },
|
|
240
|
-
hour: function (param) { return new AggregationOperator('hour', param); },
|
|
241
|
-
week: function (param) { return new AggregationOperator('week', param); },
|
|
242
|
-
year: function (param) { return new AggregationOperator('year', param); },
|
|
243
|
-
literal: function (param) { return new AggregationOperator('literal', param); },
|
|
244
|
-
mergeObjects: function (param) { return new AggregationOperator('mergeObjects', param); },
|
|
245
|
-
objectToArray: function (param) { return new AggregationOperator('objectToArray', param); },
|
|
246
|
-
allElementsTrue: function (param) { return new AggregationOperator('allElementsTrue', param); },
|
|
247
|
-
anyElementTrue: function (param) { return new AggregationOperator('anyElementTrue', param); },
|
|
248
|
-
setDifference: function (param) { return new AggregationOperator('setDifference', param); },
|
|
249
|
-
setEquals: function (param) { return new AggregationOperator('setEquals', param); },
|
|
250
|
-
setIntersection: function (param) { return new AggregationOperator('setIntersection', param); },
|
|
251
|
-
setIsSubset: function (param) { return new AggregationOperator('setIsSubset', param); },
|
|
252
|
-
setUnion: function (param) { return new AggregationOperator('setUnion', param); },
|
|
253
|
-
concat: function (param) { return new AggregationOperator('concat', param); },
|
|
254
|
-
dateToString: function (param) { return new AggregationOperator('dateToString', param); },
|
|
255
|
-
indexOfBytes: function (param) { return new AggregationOperator('indexOfBytes', param); },
|
|
256
|
-
indexOfCP: function (param) { return new AggregationOperator('indexOfCP', param); },
|
|
257
|
-
split: function (param) { return new AggregationOperator('split', param); },
|
|
258
|
-
strLenBytes: function (param) { return new AggregationOperator('strLenBytes', param); },
|
|
259
|
-
strLenCP: function (param) { return new AggregationOperator('strLenCP', param); },
|
|
260
|
-
strcasecmp: function (param) { return new AggregationOperator('strcasecmp', param); },
|
|
261
|
-
substr: function (param) { return new AggregationOperator('substr', param); },
|
|
262
|
-
substrBytes: function (param) { return new AggregationOperator('substrBytes', param); },
|
|
263
|
-
substrCP: function (param) { return new AggregationOperator('substrCP', param); },
|
|
264
|
-
toLower: function (param) { return new AggregationOperator('toLower', param); },
|
|
265
|
-
toUpper: function (param) { return new AggregationOperator('toUpper', param); },
|
|
266
|
-
meta: function (param) { return new AggregationOperator('meta', param); },
|
|
267
|
-
addToSet: function (param) { return new AggregationOperator('addToSet', param); },
|
|
268
|
-
avg: function (param) { return new AggregationOperator('avg', param); },
|
|
269
|
-
first: function (param) { return new AggregationOperator('first', param); },
|
|
270
|
-
last: function (param) { return new AggregationOperator('last', param); },
|
|
271
|
-
max: function (param) { return new AggregationOperator('max', param); },
|
|
272
|
-
min: function (param) { return new AggregationOperator('min', param); },
|
|
273
|
-
push: function (param) { return new AggregationOperator('push', param); },
|
|
274
|
-
stdDevPop: function (param) { return new AggregationOperator('stdDevPop', param); },
|
|
275
|
-
stdDevSamp: function (param) { return new AggregationOperator('stdDevSamp', param); },
|
|
276
|
-
sum: function (param) { return new AggregationOperator('sum', param); },
|
|
277
|
-
let: function (param) { return new AggregationOperator('let', param); }
|
|
278
|
-
},
|
|
279
|
-
project: {
|
|
280
|
-
slice: function (param) { return new ProjectionOperator('slice', param); },
|
|
281
|
-
elemMatch: function (param) { return new ProjectionOperator('elemMatch', param); }
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
var AggregationOperator = (function () {
|
|
285
|
-
function AggregationOperator(name, param) {
|
|
286
|
-
this['$' + name] = param;
|
|
287
|
-
}
|
|
288
|
-
return AggregationOperator;
|
|
289
|
-
}());
|
|
290
|
-
var ProjectionOperator = (function () {
|
|
291
|
-
function ProjectionOperator(name, param) {
|
|
292
|
-
this['$' + name] = param;
|
|
293
|
-
}
|
|
294
|
-
return ProjectionOperator;
|
|
295
|
-
}());
|
|
296
|
-
export default Command;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { InternalSymbol } from '../helper/symbol';
|
|
2
|
-
export declare const AND = "and";
|
|
3
|
-
export declare const OR = "or";
|
|
4
|
-
export declare const NOT = "not";
|
|
5
|
-
export declare const NOR = "nor";
|
|
6
|
-
export declare enum LOGIC_COMMANDS_LITERAL {
|
|
7
|
-
AND = "and",
|
|
8
|
-
OR = "or",
|
|
9
|
-
NOT = "not",
|
|
10
|
-
NOR = "nor"
|
|
11
|
-
}
|
|
12
|
-
export declare class LogicCommand {
|
|
13
|
-
fieldName: string | InternalSymbol;
|
|
14
|
-
operator: LOGIC_COMMANDS_LITERAL | string;
|
|
15
|
-
operands: any[];
|
|
16
|
-
_internalType: InternalSymbol;
|
|
17
|
-
constructor(operator: LOGIC_COMMANDS_LITERAL | string, operands: any, fieldName?: string | InternalSymbol);
|
|
18
|
-
_setFieldName(fieldName: string): LogicCommand;
|
|
19
|
-
and(...__expressions__: LogicCommand[]): LogicCommand;
|
|
20
|
-
or(...__expressions__: LogicCommand[]): LogicCommand;
|
|
21
|
-
}
|
|
22
|
-
export declare function isLogicCommand(object: any): object is LogicCommand;
|
|
23
|
-
export declare function isKnownLogicCommand(object: any): object is LogicCommand;
|
|
24
|
-
export default LogicCommand;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { SYMBOL_UNSET_FIELD_NAME, SYMBOL_LOGIC_COMMAND } from '../helper/symbol';
|
|
2
|
-
import { isQueryCommand } from './query';
|
|
3
|
-
export var AND = 'and';
|
|
4
|
-
export var OR = 'or';
|
|
5
|
-
export var NOT = 'not';
|
|
6
|
-
export var NOR = 'nor';
|
|
7
|
-
export var LOGIC_COMMANDS_LITERAL;
|
|
8
|
-
(function (LOGIC_COMMANDS_LITERAL) {
|
|
9
|
-
LOGIC_COMMANDS_LITERAL["AND"] = "and";
|
|
10
|
-
LOGIC_COMMANDS_LITERAL["OR"] = "or";
|
|
11
|
-
LOGIC_COMMANDS_LITERAL["NOT"] = "not";
|
|
12
|
-
LOGIC_COMMANDS_LITERAL["NOR"] = "nor";
|
|
13
|
-
})(LOGIC_COMMANDS_LITERAL || (LOGIC_COMMANDS_LITERAL = {}));
|
|
14
|
-
var LogicCommand = (function () {
|
|
15
|
-
function LogicCommand(operator, operands, fieldName) {
|
|
16
|
-
this._internalType = SYMBOL_LOGIC_COMMAND;
|
|
17
|
-
Object.defineProperties(this, {
|
|
18
|
-
_internalType: {
|
|
19
|
-
enumerable: false,
|
|
20
|
-
configurable: false,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
this.operator = operator;
|
|
24
|
-
this.operands = operands;
|
|
25
|
-
this.fieldName = fieldName || SYMBOL_UNSET_FIELD_NAME;
|
|
26
|
-
if (this.fieldName !== SYMBOL_UNSET_FIELD_NAME) {
|
|
27
|
-
if (Array.isArray(operands)) {
|
|
28
|
-
operands = operands.slice();
|
|
29
|
-
this.operands = operands;
|
|
30
|
-
for (var i = 0, len = operands.length; i < len; i++) {
|
|
31
|
-
var query = operands[i];
|
|
32
|
-
if (isLogicCommand(query) || isQueryCommand(query)) {
|
|
33
|
-
operands[i] = query._setFieldName(this.fieldName);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
var query = operands;
|
|
39
|
-
if (isLogicCommand(query) || isQueryCommand(query)) {
|
|
40
|
-
operands = query._setFieldName(this.fieldName);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
LogicCommand.prototype._setFieldName = function (fieldName) {
|
|
46
|
-
var operands = this.operands.map(function (operand) {
|
|
47
|
-
if (operand instanceof LogicCommand) {
|
|
48
|
-
return operand._setFieldName(fieldName);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return operand;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
var command = new LogicCommand(this.operator, operands, fieldName);
|
|
55
|
-
return command;
|
|
56
|
-
};
|
|
57
|
-
LogicCommand.prototype.and = function () {
|
|
58
|
-
var __expressions__ = [];
|
|
59
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
60
|
-
__expressions__[_i] = arguments[_i];
|
|
61
|
-
}
|
|
62
|
-
var expressions = Array.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
63
|
-
expressions.unshift(this);
|
|
64
|
-
return new LogicCommand(LOGIC_COMMANDS_LITERAL.AND, expressions, this.fieldName);
|
|
65
|
-
};
|
|
66
|
-
LogicCommand.prototype.or = function () {
|
|
67
|
-
var __expressions__ = [];
|
|
68
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
69
|
-
__expressions__[_i] = arguments[_i];
|
|
70
|
-
}
|
|
71
|
-
var expressions = Array.isArray(arguments[0]) ? arguments[0] : Array.from(arguments);
|
|
72
|
-
expressions.unshift(this);
|
|
73
|
-
return new LogicCommand(LOGIC_COMMANDS_LITERAL.OR, expressions, this.fieldName);
|
|
74
|
-
};
|
|
75
|
-
return LogicCommand;
|
|
76
|
-
}());
|
|
77
|
-
export { LogicCommand };
|
|
78
|
-
export function isLogicCommand(object) {
|
|
79
|
-
return object && (object instanceof LogicCommand) && (object._internalType === SYMBOL_LOGIC_COMMAND);
|
|
80
|
-
}
|
|
81
|
-
export function isKnownLogicCommand(object) {
|
|
82
|
-
return isLogicCommand && (object.operator.toUpperCase() in LOGIC_COMMANDS_LITERAL);
|
|
83
|
-
}
|
|
84
|
-
export default LogicCommand;
|