mongo-aggro 0.1.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
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.
- mongo_aggro/__init__.py +400 -0
- mongo_aggro/accumulators.py +30 -12
- mongo_aggro/base.py +49 -9
- mongo_aggro/expressions/__init__.py +396 -0
- mongo_aggro/expressions/arithmetic.py +329 -0
- mongo_aggro/expressions/array.py +425 -0
- mongo_aggro/expressions/base.py +180 -0
- mongo_aggro/expressions/bitwise.py +84 -0
- mongo_aggro/expressions/comparison.py +161 -0
- mongo_aggro/expressions/conditional.py +117 -0
- mongo_aggro/expressions/date.py +665 -0
- mongo_aggro/expressions/encrypted.py +116 -0
- mongo_aggro/expressions/logical.py +72 -0
- mongo_aggro/expressions/object.py +122 -0
- mongo_aggro/expressions/set.py +150 -0
- mongo_aggro/expressions/size.py +48 -0
- mongo_aggro/expressions/string.py +365 -0
- mongo_aggro/expressions/trigonometry.py +283 -0
- mongo_aggro/expressions/type.py +205 -0
- mongo_aggro/expressions/variable.py +73 -0
- mongo_aggro/expressions/window.py +327 -0
- mongo_aggro/operators/__init__.py +65 -0
- mongo_aggro/operators/array.py +41 -0
- mongo_aggro/operators/base.py +15 -0
- mongo_aggro/operators/bitwise.py +81 -0
- mongo_aggro/operators/comparison.py +82 -0
- mongo_aggro/operators/element.py +32 -0
- mongo_aggro/operators/geo.py +171 -0
- mongo_aggro/operators/logical.py +111 -0
- mongo_aggro/operators/misc.py +102 -0
- mongo_aggro/operators/regex.py +25 -0
- mongo_aggro/stages/__init__.py +110 -0
- mongo_aggro/stages/array.py +69 -0
- mongo_aggro/stages/change.py +109 -0
- mongo_aggro/stages/core.py +170 -0
- mongo_aggro/stages/geo.py +93 -0
- mongo_aggro/stages/group.py +154 -0
- mongo_aggro/stages/join.py +221 -0
- mongo_aggro/stages/misc.py +45 -0
- mongo_aggro/stages/output.py +136 -0
- mongo_aggro/stages/search.py +315 -0
- mongo_aggro/stages/session.py +111 -0
- mongo_aggro/stages/stats.py +152 -0
- mongo_aggro/stages/transform.py +136 -0
- mongo_aggro/stages/window.py +139 -0
- mongo_aggro-0.2.2.dist-info/METADATA +193 -0
- mongo_aggro-0.2.2.dist-info/RECORD +49 -0
- {mongo_aggro-0.1.0.dist-info → mongo_aggro-0.2.2.dist-info}/WHEEL +1 -1
- mongo_aggro/operators.py +0 -247
- mongo_aggro/stages.py +0 -990
- mongo_aggro-0.1.0.dist-info/METADATA +0 -537
- mongo_aggro-0.1.0.dist-info/RECORD +0 -9
- {mongo_aggro-0.1.0.dist-info → mongo_aggro-0.2.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""String expression operators for MongoDB aggregation."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import model_serializer
|
|
6
|
+
|
|
7
|
+
from mongo_aggro.base import serialize_value
|
|
8
|
+
from mongo_aggro.expressions.base import ExpressionBase
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ConcatExpr(ExpressionBase):
|
|
12
|
+
"""
|
|
13
|
+
$concat expression operator - concatenates strings.
|
|
14
|
+
|
|
15
|
+
Example:
|
|
16
|
+
>>> ConcatExpr(strings=[F("first"), " ", F("last")]).model_dump()
|
|
17
|
+
{"$concat": ["$first", " ", "$last"]}
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
strings: list[Any]
|
|
21
|
+
|
|
22
|
+
@model_serializer
|
|
23
|
+
def serialize(self) -> dict[str, Any]:
|
|
24
|
+
"""Serialize to MongoDB $concat expression."""
|
|
25
|
+
return {"$concat": [serialize_value(s) for s in self.strings]}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SplitExpr(ExpressionBase):
|
|
29
|
+
"""
|
|
30
|
+
$split expression operator - splits string by delimiter.
|
|
31
|
+
|
|
32
|
+
Example:
|
|
33
|
+
>>> SplitExpr(input=F("fullName"), delimiter=" ").model_dump()
|
|
34
|
+
{"$split": ["$fullName", " "]}
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
input: Any
|
|
38
|
+
delimiter: str
|
|
39
|
+
|
|
40
|
+
@model_serializer
|
|
41
|
+
def serialize(self) -> dict[str, Any]:
|
|
42
|
+
"""Serialize to MongoDB $split expression."""
|
|
43
|
+
return {"$split": [serialize_value(self.input), self.delimiter]}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ToLowerExpr(ExpressionBase):
|
|
47
|
+
"""
|
|
48
|
+
$toLower expression operator - converts to lowercase.
|
|
49
|
+
|
|
50
|
+
Example:
|
|
51
|
+
>>> ToLowerExpr(input=F("name")).model_dump()
|
|
52
|
+
{"$toLower": "$name"}
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
input: Any
|
|
56
|
+
|
|
57
|
+
@model_serializer
|
|
58
|
+
def serialize(self) -> dict[str, Any]:
|
|
59
|
+
"""Serialize to MongoDB $toLower expression."""
|
|
60
|
+
return {"$toLower": serialize_value(self.input)}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ToUpperExpr(ExpressionBase):
|
|
64
|
+
"""
|
|
65
|
+
$toUpper expression operator - converts to uppercase.
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
>>> ToUpperExpr(input=F("name")).model_dump()
|
|
69
|
+
{"$toUpper": "$name"}
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
input: Any
|
|
73
|
+
|
|
74
|
+
@model_serializer
|
|
75
|
+
def serialize(self) -> dict[str, Any]:
|
|
76
|
+
"""Serialize to MongoDB $toUpper expression."""
|
|
77
|
+
return {"$toUpper": serialize_value(self.input)}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class TrimExpr(ExpressionBase):
|
|
81
|
+
"""
|
|
82
|
+
$trim expression operator - trims whitespace from both ends.
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
>>> TrimExpr(input=F("text")).model_dump()
|
|
86
|
+
{"$trim": {"input": "$text"}}
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
input: Any
|
|
90
|
+
chars: str | None = None
|
|
91
|
+
|
|
92
|
+
@model_serializer
|
|
93
|
+
def serialize(self) -> dict[str, Any]:
|
|
94
|
+
"""Serialize to MongoDB $trim expression."""
|
|
95
|
+
result: dict[str, Any] = {
|
|
96
|
+
"$trim": {"input": serialize_value(self.input)}
|
|
97
|
+
}
|
|
98
|
+
if self.chars is not None:
|
|
99
|
+
result["$trim"]["chars"] = self.chars
|
|
100
|
+
return result
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class LTrimExpr(ExpressionBase):
|
|
104
|
+
"""
|
|
105
|
+
$ltrim expression operator - trims whitespace from left.
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
>>> LTrimExpr(input=F("text")).model_dump()
|
|
109
|
+
{"$ltrim": {"input": "$text"}}
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
input: Any
|
|
113
|
+
chars: str | None = None
|
|
114
|
+
|
|
115
|
+
@model_serializer
|
|
116
|
+
def serialize(self) -> dict[str, Any]:
|
|
117
|
+
"""Serialize to MongoDB $ltrim expression."""
|
|
118
|
+
result: dict[str, Any] = {
|
|
119
|
+
"$ltrim": {"input": serialize_value(self.input)}
|
|
120
|
+
}
|
|
121
|
+
if self.chars is not None:
|
|
122
|
+
result["$ltrim"]["chars"] = self.chars
|
|
123
|
+
return result
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class RTrimExpr(ExpressionBase):
|
|
127
|
+
"""
|
|
128
|
+
$rtrim expression operator - trims whitespace from right.
|
|
129
|
+
|
|
130
|
+
Example:
|
|
131
|
+
>>> RTrimExpr(input=F("text")).model_dump()
|
|
132
|
+
{"$rtrim": {"input": "$text"}}
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
input: Any
|
|
136
|
+
chars: str | None = None
|
|
137
|
+
|
|
138
|
+
@model_serializer
|
|
139
|
+
def serialize(self) -> dict[str, Any]:
|
|
140
|
+
"""Serialize to MongoDB $rtrim expression."""
|
|
141
|
+
result: dict[str, Any] = {
|
|
142
|
+
"$rtrim": {"input": serialize_value(self.input)}
|
|
143
|
+
}
|
|
144
|
+
if self.chars is not None:
|
|
145
|
+
result["$rtrim"]["chars"] = self.chars
|
|
146
|
+
return result
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ReplaceOneExpr(ExpressionBase):
|
|
150
|
+
"""
|
|
151
|
+
$replaceOne expression operator - replaces first occurrence.
|
|
152
|
+
|
|
153
|
+
Example:
|
|
154
|
+
>>> ReplaceOneExpr(
|
|
155
|
+
... input=F("text"),
|
|
156
|
+
... find="old",
|
|
157
|
+
... replacement="new"
|
|
158
|
+
... ).model_dump()
|
|
159
|
+
{"$replaceOne": {"input": "$text", "find": "old", "replacement": "new"}}
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
input: Any
|
|
163
|
+
find: Any
|
|
164
|
+
replacement: Any
|
|
165
|
+
|
|
166
|
+
@model_serializer
|
|
167
|
+
def serialize(self) -> dict[str, Any]:
|
|
168
|
+
"""Serialize to MongoDB $replaceOne expression."""
|
|
169
|
+
return {
|
|
170
|
+
"$replaceOne": {
|
|
171
|
+
"input": serialize_value(self.input),
|
|
172
|
+
"find": serialize_value(self.find),
|
|
173
|
+
"replacement": serialize_value(self.replacement),
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class ReplaceAllExpr(ExpressionBase):
|
|
179
|
+
"""
|
|
180
|
+
$replaceAll expression operator - replaces all occurrences.
|
|
181
|
+
|
|
182
|
+
Example:
|
|
183
|
+
>>> ReplaceAllExpr(
|
|
184
|
+
... input=F("text"),
|
|
185
|
+
... find="old",
|
|
186
|
+
... replacement="new"
|
|
187
|
+
... ).model_dump()
|
|
188
|
+
{"$replaceAll": {"input": "$text", "find": "old", "replacement": "new"}}
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
input: Any
|
|
192
|
+
find: Any
|
|
193
|
+
replacement: Any
|
|
194
|
+
|
|
195
|
+
@model_serializer
|
|
196
|
+
def serialize(self) -> dict[str, Any]:
|
|
197
|
+
"""Serialize to MongoDB $replaceAll expression."""
|
|
198
|
+
return {
|
|
199
|
+
"$replaceAll": {
|
|
200
|
+
"input": serialize_value(self.input),
|
|
201
|
+
"find": serialize_value(self.find),
|
|
202
|
+
"replacement": serialize_value(self.replacement),
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class RegexMatchExpr(ExpressionBase):
|
|
208
|
+
"""
|
|
209
|
+
$regexMatch expression operator - tests if string matches regex.
|
|
210
|
+
|
|
211
|
+
Example:
|
|
212
|
+
>>> RegexMatchExpr(input=F("email"), regex=r"@.*\\.com$").model_dump()
|
|
213
|
+
{"$regexMatch": {"input": "$email", "regex": "@.*\\\\.com$"}}
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
input: Any
|
|
217
|
+
regex: str
|
|
218
|
+
options: str | None = None
|
|
219
|
+
|
|
220
|
+
@model_serializer
|
|
221
|
+
def serialize(self) -> dict[str, Any]:
|
|
222
|
+
"""Serialize to MongoDB $regexMatch expression."""
|
|
223
|
+
result: dict[str, Any] = {
|
|
224
|
+
"$regexMatch": {
|
|
225
|
+
"input": serialize_value(self.input),
|
|
226
|
+
"regex": self.regex,
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if self.options is not None:
|
|
230
|
+
result["$regexMatch"]["options"] = self.options
|
|
231
|
+
return result
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class RegexFindExpr(ExpressionBase):
|
|
235
|
+
"""
|
|
236
|
+
$regexFind expression operator - finds first regex match.
|
|
237
|
+
|
|
238
|
+
Example:
|
|
239
|
+
>>> RegexFindExpr(input=F("text"), regex=r"\\d+").model_dump()
|
|
240
|
+
{"$regexFind": {"input": "$text", "regex": "\\\\d+"}}
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
input: Any
|
|
244
|
+
regex: str
|
|
245
|
+
options: str | None = None
|
|
246
|
+
|
|
247
|
+
@model_serializer
|
|
248
|
+
def serialize(self) -> dict[str, Any]:
|
|
249
|
+
"""Serialize to MongoDB $regexFind expression."""
|
|
250
|
+
result: dict[str, Any] = {
|
|
251
|
+
"$regexFind": {
|
|
252
|
+
"input": serialize_value(self.input),
|
|
253
|
+
"regex": self.regex,
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if self.options is not None:
|
|
257
|
+
result["$regexFind"]["options"] = self.options
|
|
258
|
+
return result
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class RegexFindAllExpr(ExpressionBase):
|
|
262
|
+
"""
|
|
263
|
+
$regexFindAll expression operator - finds all regex matches.
|
|
264
|
+
|
|
265
|
+
Example:
|
|
266
|
+
>>> RegexFindAllExpr(input=F("text"), regex=r"\\w+").model_dump()
|
|
267
|
+
{"$regexFindAll": {"input": "$text", "regex": "\\\\w+"}}
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
input: Any
|
|
271
|
+
regex: str
|
|
272
|
+
options: str | None = None
|
|
273
|
+
|
|
274
|
+
@model_serializer
|
|
275
|
+
def serialize(self) -> dict[str, Any]:
|
|
276
|
+
"""Serialize to MongoDB $regexFindAll expression."""
|
|
277
|
+
result: dict[str, Any] = {
|
|
278
|
+
"$regexFindAll": {
|
|
279
|
+
"input": serialize_value(self.input),
|
|
280
|
+
"regex": self.regex,
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if self.options is not None:
|
|
284
|
+
result["$regexFindAll"]["options"] = self.options
|
|
285
|
+
return result
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
class SubstrCPExpr(ExpressionBase):
|
|
289
|
+
"""
|
|
290
|
+
$substrCP expression operator - substring by code points.
|
|
291
|
+
|
|
292
|
+
Example:
|
|
293
|
+
>>> SubstrCPExpr(input=F("text"), start=0, length=5).model_dump()
|
|
294
|
+
{"$substrCP": ["$text", 0, 5]}
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
input: Any
|
|
298
|
+
start: int
|
|
299
|
+
length: int
|
|
300
|
+
|
|
301
|
+
@model_serializer
|
|
302
|
+
def serialize(self) -> dict[str, Any]:
|
|
303
|
+
"""Serialize to MongoDB $substrCP expression."""
|
|
304
|
+
return {
|
|
305
|
+
"$substrCP": [serialize_value(self.input), self.start, self.length]
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class StrLenCPExpr(ExpressionBase):
|
|
310
|
+
"""
|
|
311
|
+
$strLenCP expression operator - string length in code points.
|
|
312
|
+
|
|
313
|
+
Example:
|
|
314
|
+
>>> StrLenCPExpr(input=F("text")).model_dump()
|
|
315
|
+
{"$strLenCP": "$text"}
|
|
316
|
+
"""
|
|
317
|
+
|
|
318
|
+
input: Any
|
|
319
|
+
|
|
320
|
+
@model_serializer
|
|
321
|
+
def serialize(self) -> dict[str, Any]:
|
|
322
|
+
"""Serialize to MongoDB $strLenCP expression."""
|
|
323
|
+
return {"$strLenCP": serialize_value(self.input)}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
class StrCaseCmpExpr(ExpressionBase):
|
|
327
|
+
"""
|
|
328
|
+
$strcasecmp expression operator - case-insensitive string comparison.
|
|
329
|
+
|
|
330
|
+
Example:
|
|
331
|
+
>>> StrCaseCmpExpr(first=F("a"), second=F("b")).model_dump()
|
|
332
|
+
{"$strcasecmp": ["$a", "$b"]}
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
first: Any
|
|
336
|
+
second: Any
|
|
337
|
+
|
|
338
|
+
@model_serializer
|
|
339
|
+
def serialize(self) -> dict[str, Any]:
|
|
340
|
+
"""Serialize to MongoDB $strcasecmp expression."""
|
|
341
|
+
return {
|
|
342
|
+
"$strcasecmp": [
|
|
343
|
+
serialize_value(self.first),
|
|
344
|
+
serialize_value(self.second),
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
__all__ = [
|
|
350
|
+
"ConcatExpr",
|
|
351
|
+
"SplitExpr",
|
|
352
|
+
"ToLowerExpr",
|
|
353
|
+
"ToUpperExpr",
|
|
354
|
+
"TrimExpr",
|
|
355
|
+
"LTrimExpr",
|
|
356
|
+
"RTrimExpr",
|
|
357
|
+
"ReplaceOneExpr",
|
|
358
|
+
"ReplaceAllExpr",
|
|
359
|
+
"RegexMatchExpr",
|
|
360
|
+
"RegexFindExpr",
|
|
361
|
+
"RegexFindAllExpr",
|
|
362
|
+
"SubstrCPExpr",
|
|
363
|
+
"StrLenCPExpr",
|
|
364
|
+
"StrCaseCmpExpr",
|
|
365
|
+
]
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"""Trigonometry expression operators for MongoDB aggregation."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import model_serializer
|
|
6
|
+
|
|
7
|
+
from mongo_aggro.base import serialize_value
|
|
8
|
+
from mongo_aggro.expressions.base import ExpressionBase
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SinExpr(ExpressionBase):
|
|
12
|
+
"""
|
|
13
|
+
$sin expression operator - calculates sine.
|
|
14
|
+
|
|
15
|
+
Example:
|
|
16
|
+
>>> SinExpr(input=F("angle")).model_dump()
|
|
17
|
+
{"$sin": "$angle"}
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
input: Any
|
|
21
|
+
|
|
22
|
+
@model_serializer
|
|
23
|
+
def serialize(self) -> dict[str, Any]:
|
|
24
|
+
"""Serialize to MongoDB $sin expression."""
|
|
25
|
+
return {"$sin": serialize_value(self.input)}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CosExpr(ExpressionBase):
|
|
29
|
+
"""
|
|
30
|
+
$cos expression operator - calculates cosine.
|
|
31
|
+
|
|
32
|
+
Example:
|
|
33
|
+
>>> CosExpr(input=F("angle")).model_dump()
|
|
34
|
+
{"$cos": "$angle"}
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
input: Any
|
|
38
|
+
|
|
39
|
+
@model_serializer
|
|
40
|
+
def serialize(self) -> dict[str, Any]:
|
|
41
|
+
"""Serialize to MongoDB $cos expression."""
|
|
42
|
+
return {"$cos": serialize_value(self.input)}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class TanExpr(ExpressionBase):
|
|
46
|
+
"""
|
|
47
|
+
$tan expression operator - calculates tangent.
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
>>> TanExpr(input=F("angle")).model_dump()
|
|
51
|
+
{"$tan": "$angle"}
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
input: Any
|
|
55
|
+
|
|
56
|
+
@model_serializer
|
|
57
|
+
def serialize(self) -> dict[str, Any]:
|
|
58
|
+
"""Serialize to MongoDB $tan expression."""
|
|
59
|
+
return {"$tan": serialize_value(self.input)}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AsinExpr(ExpressionBase):
|
|
63
|
+
"""
|
|
64
|
+
$asin expression operator - calculates arc sine.
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
>>> AsinExpr(input=F("value")).model_dump()
|
|
68
|
+
{"$asin": "$value"}
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
input: Any
|
|
72
|
+
|
|
73
|
+
@model_serializer
|
|
74
|
+
def serialize(self) -> dict[str, Any]:
|
|
75
|
+
"""Serialize to MongoDB $asin expression."""
|
|
76
|
+
return {"$asin": serialize_value(self.input)}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class AcosExpr(ExpressionBase):
|
|
80
|
+
"""
|
|
81
|
+
$acos expression operator - calculates arc cosine.
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
>>> AcosExpr(input=F("value")).model_dump()
|
|
85
|
+
{"$acos": "$value"}
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
input: Any
|
|
89
|
+
|
|
90
|
+
@model_serializer
|
|
91
|
+
def serialize(self) -> dict[str, Any]:
|
|
92
|
+
"""Serialize to MongoDB $acos expression."""
|
|
93
|
+
return {"$acos": serialize_value(self.input)}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AtanExpr(ExpressionBase):
|
|
97
|
+
"""
|
|
98
|
+
$atan expression operator - calculates arc tangent.
|
|
99
|
+
|
|
100
|
+
Example:
|
|
101
|
+
>>> AtanExpr(input=F("value")).model_dump()
|
|
102
|
+
{"$atan": "$value"}
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
input: Any
|
|
106
|
+
|
|
107
|
+
@model_serializer
|
|
108
|
+
def serialize(self) -> dict[str, Any]:
|
|
109
|
+
"""Serialize to MongoDB $atan expression."""
|
|
110
|
+
return {"$atan": serialize_value(self.input)}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class Atan2Expr(ExpressionBase):
|
|
114
|
+
"""
|
|
115
|
+
$atan2 expression operator - calculates arc tangent of y/x.
|
|
116
|
+
|
|
117
|
+
Example:
|
|
118
|
+
>>> Atan2Expr(y=F("y"), x=F("x")).model_dump()
|
|
119
|
+
{"$atan2": ["$y", "$x"]}
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
y: Any
|
|
123
|
+
x: Any
|
|
124
|
+
|
|
125
|
+
@model_serializer
|
|
126
|
+
def serialize(self) -> dict[str, Any]:
|
|
127
|
+
"""Serialize to MongoDB $atan2 expression."""
|
|
128
|
+
return {"$atan2": [serialize_value(self.y), serialize_value(self.x)]}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class SinhExpr(ExpressionBase):
|
|
132
|
+
"""
|
|
133
|
+
$sinh expression operator - calculates hyperbolic sine.
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
>>> SinhExpr(input=F("value")).model_dump()
|
|
137
|
+
{"$sinh": "$value"}
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
input: Any
|
|
141
|
+
|
|
142
|
+
@model_serializer
|
|
143
|
+
def serialize(self) -> dict[str, Any]:
|
|
144
|
+
"""Serialize to MongoDB $sinh expression."""
|
|
145
|
+
return {"$sinh": serialize_value(self.input)}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class CoshExpr(ExpressionBase):
|
|
149
|
+
"""
|
|
150
|
+
$cosh expression operator - calculates hyperbolic cosine.
|
|
151
|
+
|
|
152
|
+
Example:
|
|
153
|
+
>>> CoshExpr(input=F("value")).model_dump()
|
|
154
|
+
{"$cosh": "$value"}
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
input: Any
|
|
158
|
+
|
|
159
|
+
@model_serializer
|
|
160
|
+
def serialize(self) -> dict[str, Any]:
|
|
161
|
+
"""Serialize to MongoDB $cosh expression."""
|
|
162
|
+
return {"$cosh": serialize_value(self.input)}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class TanhExpr(ExpressionBase):
|
|
166
|
+
"""
|
|
167
|
+
$tanh expression operator - calculates hyperbolic tangent.
|
|
168
|
+
|
|
169
|
+
Example:
|
|
170
|
+
>>> TanhExpr(input=F("value")).model_dump()
|
|
171
|
+
{"$tanh": "$value"}
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
input: Any
|
|
175
|
+
|
|
176
|
+
@model_serializer
|
|
177
|
+
def serialize(self) -> dict[str, Any]:
|
|
178
|
+
"""Serialize to MongoDB $tanh expression."""
|
|
179
|
+
return {"$tanh": serialize_value(self.input)}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class AsinhExpr(ExpressionBase):
|
|
183
|
+
"""
|
|
184
|
+
$asinh expression operator - calculates hyperbolic arc sine.
|
|
185
|
+
|
|
186
|
+
Example:
|
|
187
|
+
>>> AsinhExpr(input=F("value")).model_dump()
|
|
188
|
+
{"$asinh": "$value"}
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
input: Any
|
|
192
|
+
|
|
193
|
+
@model_serializer
|
|
194
|
+
def serialize(self) -> dict[str, Any]:
|
|
195
|
+
"""Serialize to MongoDB $asinh expression."""
|
|
196
|
+
return {"$asinh": serialize_value(self.input)}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class AcoshExpr(ExpressionBase):
|
|
200
|
+
"""
|
|
201
|
+
$acosh expression operator - calculates hyperbolic arc cosine.
|
|
202
|
+
|
|
203
|
+
Example:
|
|
204
|
+
>>> AcoshExpr(input=F("value")).model_dump()
|
|
205
|
+
{"$acosh": "$value"}
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
input: Any
|
|
209
|
+
|
|
210
|
+
@model_serializer
|
|
211
|
+
def serialize(self) -> dict[str, Any]:
|
|
212
|
+
"""Serialize to MongoDB $acosh expression."""
|
|
213
|
+
return {"$acosh": serialize_value(self.input)}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class AtanhExpr(ExpressionBase):
|
|
217
|
+
"""
|
|
218
|
+
$atanh expression operator - calculates hyperbolic arc tangent.
|
|
219
|
+
|
|
220
|
+
Example:
|
|
221
|
+
>>> AtanhExpr(input=F("value")).model_dump()
|
|
222
|
+
{"$atanh": "$value"}
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
input: Any
|
|
226
|
+
|
|
227
|
+
@model_serializer
|
|
228
|
+
def serialize(self) -> dict[str, Any]:
|
|
229
|
+
"""Serialize to MongoDB $atanh expression."""
|
|
230
|
+
return {"$atanh": serialize_value(self.input)}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class DegreesToRadiansExpr(ExpressionBase):
|
|
234
|
+
"""
|
|
235
|
+
$degreesToRadians expression operator - converts degrees to radians.
|
|
236
|
+
|
|
237
|
+
Example:
|
|
238
|
+
>>> DegreesToRadiansExpr(input=F("degrees")).model_dump()
|
|
239
|
+
{"$degreesToRadians": "$degrees"}
|
|
240
|
+
"""
|
|
241
|
+
|
|
242
|
+
input: Any
|
|
243
|
+
|
|
244
|
+
@model_serializer
|
|
245
|
+
def serialize(self) -> dict[str, Any]:
|
|
246
|
+
"""Serialize to MongoDB $degreesToRadians expression."""
|
|
247
|
+
return {"$degreesToRadians": serialize_value(self.input)}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class RadiansToDegreesExpr(ExpressionBase):
|
|
251
|
+
"""
|
|
252
|
+
$radiansToDegrees expression operator - converts radians to degrees.
|
|
253
|
+
|
|
254
|
+
Example:
|
|
255
|
+
>>> RadiansToDegreesExpr(input=F("radians")).model_dump()
|
|
256
|
+
{"$radiansToDegrees": "$radians"}
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
input: Any
|
|
260
|
+
|
|
261
|
+
@model_serializer
|
|
262
|
+
def serialize(self) -> dict[str, Any]:
|
|
263
|
+
"""Serialize to MongoDB $radiansToDegrees expression."""
|
|
264
|
+
return {"$radiansToDegrees": serialize_value(self.input)}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
__all__ = [
|
|
268
|
+
"SinExpr",
|
|
269
|
+
"CosExpr",
|
|
270
|
+
"TanExpr",
|
|
271
|
+
"AsinExpr",
|
|
272
|
+
"AcosExpr",
|
|
273
|
+
"AtanExpr",
|
|
274
|
+
"Atan2Expr",
|
|
275
|
+
"SinhExpr",
|
|
276
|
+
"CoshExpr",
|
|
277
|
+
"TanhExpr",
|
|
278
|
+
"AsinhExpr",
|
|
279
|
+
"AcoshExpr",
|
|
280
|
+
"AtanhExpr",
|
|
281
|
+
"DegreesToRadiansExpr",
|
|
282
|
+
"RadiansToDegreesExpr",
|
|
283
|
+
]
|