aggify 0.3.8__tar.gz → 1.0.0__tar.gz

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.
Files changed (104) hide show
  1. aggify-1.0.0/.gitignore +314 -0
  2. aggify-1.0.0/PKG-INFO +189 -0
  3. aggify-1.0.0/README.md +130 -0
  4. aggify-1.0.0/SECURITY.md +48 -0
  5. aggify-1.0.0/aggify/__init__.py +104 -0
  6. aggify-1.0.0/aggify/conf.py +46 -0
  7. aggify-1.0.0/aggify/connection.py +260 -0
  8. aggify-1.0.0/aggify/contrib/__init__.py +1 -0
  9. aggify-1.0.0/aggify/contrib/django/__init__.py +13 -0
  10. aggify-1.0.0/aggify/contrib/django/apps.py +13 -0
  11. aggify-1.0.0/aggify/contrib/django/conf.py +30 -0
  12. aggify-1.0.0/aggify/contrib/django/fields.py +44 -0
  13. aggify-1.0.0/aggify/contrib/django/forms.py +108 -0
  14. aggify-1.0.0/aggify/contrib/django/management/__init__.py +0 -0
  15. aggify-1.0.0/aggify/contrib/django/management/commands/__init__.py +0 -0
  16. aggify-1.0.0/aggify/contrib/django/management/commands/aggify_indexes.py +27 -0
  17. aggify-1.0.0/aggify/contrib/django/middleware.py +30 -0
  18. aggify-1.0.0/aggify/contrib/django/shortcuts.py +32 -0
  19. aggify-1.0.0/aggify/contrib/fastapi.py +113 -0
  20. aggify-1.0.0/aggify/contrib/grpc.py +88 -0
  21. aggify-1.0.0/aggify/contrib/pydantic.py +174 -0
  22. aggify-1.0.0/aggify/documents.py +788 -0
  23. aggify-1.0.0/aggify/exceptions.py +197 -0
  24. aggify-1.0.0/aggify/expressions.py +1226 -0
  25. aggify-1.0.0/aggify/fields.py +1018 -0
  26. aggify-1.0.0/aggify/indexes.py +97 -0
  27. aggify-1.0.0/aggify/lookups.py +345 -0
  28. aggify-1.0.0/aggify/monitoring.py +136 -0
  29. aggify-1.0.0/aggify/pipeline.py +916 -0
  30. aggify-1.0.0/aggify/py.typed +0 -0
  31. aggify-1.0.0/aggify/queryset.py +1056 -0
  32. aggify-1.0.0/aggify/registry.py +46 -0
  33. aggify-1.0.0/aggify/schema.py +246 -0
  34. aggify-1.0.0/aggify/security.py +131 -0
  35. aggify-1.0.0/aggify/signals.py +89 -0
  36. aggify-1.0.0/aggify/testing.py +45 -0
  37. aggify-1.0.0/aggify/updates.py +176 -0
  38. aggify-1.0.0/docs/aggregation.md +86 -0
  39. aggify-1.0.0/docs/async.md +57 -0
  40. aggify-1.0.0/docs/cookbook.md +112 -0
  41. aggify-1.0.0/docs/examples/complex_queries.py +151 -0
  42. aggify-1.0.0/docs/examples/quickstart.py +47 -0
  43. aggify-1.0.0/docs/examples/shop_models.py +61 -0
  44. aggify-1.0.0/docs/expressions.md +91 -0
  45. aggify-1.0.0/docs/fa.md +87 -0
  46. aggify-1.0.0/docs/index.md +64 -0
  47. aggify-1.0.0/docs/integrations/django.md +76 -0
  48. aggify-1.0.0/docs/integrations/fastapi.md +63 -0
  49. aggify-1.0.0/docs/integrations/grpc.md +65 -0
  50. aggify-1.0.0/docs/integrations/pydantic.md +22 -0
  51. aggify-1.0.0/docs/migration/aggify-0.md +55 -0
  52. aggify-1.0.0/docs/migration/mongoengine.md +51 -0
  53. aggify-1.0.0/docs/models.md +167 -0
  54. aggify-1.0.0/docs/performance.md +30 -0
  55. aggify-1.0.0/docs/querying.md +162 -0
  56. aggify-1.0.0/docs/quickstart.md +89 -0
  57. aggify-1.0.0/docs/reference.md +49 -0
  58. aggify-1.0.0/docs/security.md +92 -0
  59. aggify-1.0.0/docs/testing.md +79 -0
  60. aggify-1.0.0/docs/transactions.md +30 -0
  61. aggify-1.0.0/mkdocs.yml +54 -0
  62. aggify-1.0.0/pyproject.toml +89 -0
  63. aggify-1.0.0/tests/__init__.py +0 -0
  64. aggify-1.0.0/tests/conftest.py +84 -0
  65. aggify-1.0.0/tests/contrib/__init__.py +0 -0
  66. aggify-1.0.0/tests/contrib/conftest.py +19 -0
  67. aggify-1.0.0/tests/contrib/django_urls.py +34 -0
  68. aggify-1.0.0/tests/contrib/test_cov_contrib.py +254 -0
  69. aggify-1.0.0/tests/contrib/test_django.py +150 -0
  70. aggify-1.0.0/tests/contrib/test_fastapi.py +144 -0
  71. aggify-1.0.0/tests/contrib/test_grpc.py +130 -0
  72. aggify-1.0.0/tests/contrib/test_pydantic.py +76 -0
  73. aggify-1.0.0/tests/integration/__init__.py +0 -0
  74. aggify-1.0.0/tests/integration/conftest.py +12 -0
  75. aggify-1.0.0/tests/integration/test_cov_db.py +329 -0
  76. aggify-1.0.0/tests/integration/test_cov_db2.py +131 -0
  77. aggify-1.0.0/tests/integration/test_crud.py +247 -0
  78. aggify-1.0.0/tests/integration/test_differential.py +142 -0
  79. aggify-1.0.0/tests/integration/test_pipeline_exec.py +199 -0
  80. aggify-1.0.0/tests/integration/test_queryset.py +482 -0
  81. aggify-1.0.0/tests/integration/test_signals_indexes_loops.py +220 -0
  82. aggify-1.0.0/tests/integration/test_transactions.py +84 -0
  83. aggify-1.0.0/tests/models.py +103 -0
  84. aggify-1.0.0/tests/test_cov_final.py +247 -0
  85. aggify-1.0.0/tests/test_cov_unit.py +744 -0
  86. aggify-1.0.0/tests/test_coverage_gaps.py +192 -0
  87. aggify-1.0.0/tests/test_docs_examples.py +29 -0
  88. aggify-1.0.0/tests/test_documents_unit.py +235 -0
  89. aggify-1.0.0/tests/test_expressions.py +199 -0
  90. aggify-1.0.0/tests/test_fields.py +227 -0
  91. aggify-1.0.0/tests/test_pipeline.py +400 -0
  92. aggify-1.0.0/tests/test_query_compile.py +197 -0
  93. aggify-1.0.0/tests/test_security.py +220 -0
  94. aggify-1.0.0/tests/test_updates.py +117 -0
  95. aggify-0.3.8/PKG-INFO +0 -241
  96. aggify-0.3.8/README.md +0 -221
  97. aggify-0.3.8/aggify/__init__.py +0 -9
  98. aggify-0.3.8/aggify/aggify.py +0 -912
  99. aggify-0.3.8/aggify/compiler.py +0 -328
  100. aggify-0.3.8/aggify/exceptions.py +0 -88
  101. aggify-0.3.8/aggify/types.py +0 -6
  102. aggify-0.3.8/aggify/utilty.py +0 -189
  103. aggify-0.3.8/pyproject.toml +0 -31
  104. {aggify-0.3.8 → aggify-1.0.0}/LICENSE +0 -0
@@ -0,0 +1,314 @@
1
+ ### PyCharm ###
2
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
3
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
4
+
5
+ # User-specific stuff
6
+ .idea/**/workspace.xml
7
+ .idea/**/tasks.xml
8
+ .idea/**/usage.statistics.xml
9
+ .idea/**/dictionaries
10
+ .idea/**/shelf
11
+ .idea/*
12
+ .vscode
13
+
14
+ # AWS User-specific
15
+ .idea/**/aws.xml
16
+
17
+ # Generated files
18
+ .idea/**/contentModel.xml
19
+
20
+ # Sensitive or high-churn files
21
+ .idea/**/dataSources/
22
+ .idea/**/dataSources.ids
23
+ .idea/**/dataSources.local.xml
24
+ .idea/**/sqlDataSources.xml
25
+ .idea/**/dynamic.xml
26
+ .idea/**/uiDesigner.xml
27
+ .idea/**/dbnavigator.xml
28
+
29
+ # Gradle
30
+ .idea/**/gradle.xml
31
+ .idea/**/libraries
32
+
33
+ # Gradle and Maven with auto-import
34
+ # When using Gradle or Maven with auto-import, you should exclude module files,
35
+ # since they will be recreated, and may cause churn. Uncomment if using
36
+ # auto-import.
37
+ # .idea/artifacts
38
+ # .idea/compiler.xml
39
+ # .idea/jarRepositories.xml
40
+ # .idea/modules.xml
41
+ # .idea/*.iml
42
+ # .idea/modules
43
+ # *.iml
44
+ # *.ipr
45
+
46
+ # CMake
47
+ cmake-build-*/
48
+
49
+ # Mongo Explorer plugin
50
+ .idea/**/mongoSettings.xml
51
+
52
+ # File-based project format
53
+ *.iws
54
+
55
+ # IntelliJ
56
+ out/
57
+
58
+ # mpeltonen/sbt-idea plugin
59
+ .idea_modules/
60
+
61
+ # JIRA plugin
62
+ atlassian-ide-plugin.xml
63
+
64
+ # Cursive Clojure plugin
65
+ .idea/replstate.xml
66
+
67
+ # SonarLint plugin
68
+ .idea/sonarlint/
69
+
70
+ # Crashlytics plugin (for Android Studio and IntelliJ)
71
+ com_crashlytics_export_strings.xml
72
+ crashlytics.properties
73
+ crashlytics-build.properties
74
+ fabric.properties
75
+
76
+ # Editor-based Rest Client
77
+ .idea/httpRequests
78
+
79
+ # Android studio 3.1+ serialized cache file
80
+ .idea/caches/build_file_checksums.ser
81
+
82
+ ### PyCharm Patch ###
83
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
84
+
85
+ # *.iml
86
+ # modules.xml
87
+ # .idea/misc.xml
88
+ # *.ipr
89
+
90
+ # Sonarlint plugin
91
+ # https://plugins.jetbrains.com/plugin/7973-sonarlint
92
+ .idea/**/sonarlint/
93
+
94
+ # SonarQube Plugin
95
+ # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
96
+ .idea/**/sonarIssues.xml
97
+
98
+ # Markdown Navigator plugin
99
+ # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
100
+ .idea/**/markdown-navigator.xml
101
+ .idea/**/markdown-navigator-enh.xml
102
+ .idea/**/markdown-navigator/
103
+
104
+ # Cache file creation bug
105
+ # See https://youtrack.jetbrains.com/issue/JBR-2257
106
+ .idea/$CACHE_FILE$
107
+
108
+ # CodeStream plugin
109
+ # https://plugins.jetbrains.com/plugin/12206-codestream
110
+ .idea/codestream.xml
111
+
112
+ # Azure Toolkit for IntelliJ plugin
113
+ # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
114
+ .idea/**/azureSettings.xml
115
+
116
+ ### Python ###
117
+ # Byte-compiled / optimized / DLL files
118
+ __pycache__/
119
+ *.py[cod]
120
+ *$py.class
121
+
122
+ # C extensions
123
+ *.so
124
+
125
+ # Distribution / packaging
126
+ .Python
127
+ build/
128
+ develop-eggs/
129
+ dist/
130
+ downloads/
131
+ eggs/
132
+ .eggs/
133
+ lib/
134
+ lib64/
135
+ parts/
136
+ sdist/
137
+ var/
138
+ wheels/
139
+ share/python-wheels/
140
+ *.egg-info/
141
+ .installed.cfg
142
+ *.egg
143
+ MANIFEST
144
+
145
+ # PyInstaller
146
+ # Usually these files are written by a python script from a template
147
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
148
+ *.manifest
149
+ *.spec
150
+
151
+ # Installer logs
152
+ pip-log.txt
153
+ pip-delete-this-directory.txt
154
+
155
+ # Unit test / coverage reports
156
+ htmlcov/
157
+ .tox/
158
+ .nox/
159
+ .coverage
160
+ .coverage.*
161
+ .cache
162
+ nosetests.xml
163
+ coverage.xml
164
+ *.cover
165
+ *.py,cover
166
+ .hypothesis/
167
+ .pytest_cache/
168
+ cover/
169
+
170
+ # Translations
171
+ *.mo
172
+ *.pot
173
+
174
+ # Django stuff:
175
+ *.log
176
+ local_settings.py
177
+ db.sqlite3
178
+ db.sqlite3-journal
179
+
180
+ # Flask stuff:
181
+ instance/
182
+ .webassets-cache
183
+
184
+ # Scrapy stuff:
185
+ .scrapy
186
+
187
+ # Sphinx documentation
188
+ docs/_build/
189
+
190
+ # PyBuilder
191
+ .pybuilder/
192
+ target/
193
+
194
+ # Jupyter Notebook
195
+ .ipynb_checkpoints
196
+
197
+ # IPython
198
+ profile_default/
199
+ ipython_config.py
200
+
201
+ # pyenv
202
+ # For a library or package, you might want to ignore these files since the code is
203
+ # intended to run in multiple environments; otherwise, check them in:
204
+ # .python-version
205
+
206
+ # pipenv
207
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
208
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
209
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
210
+ # install all needed dependencies.
211
+ #Pipfile.lock
212
+
213
+ # poetry
214
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
215
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
216
+ # commonly ignored for libraries.
217
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
218
+ #poetry.lock
219
+
220
+ # pdm
221
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
222
+ #pdm.lock
223
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
224
+ # in version control.
225
+ # https://pdm.fming.dev/#use-with-ide
226
+ .pdm.toml
227
+
228
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
229
+ __pypackages__/
230
+
231
+ # Celery stuff
232
+ celerybeat-schedule
233
+ celerybeat.pid
234
+
235
+ # SageMath parsed files
236
+ *.sage.py
237
+
238
+ # Environments
239
+ .env
240
+ .venv
241
+ env/
242
+ venv/
243
+ ENV/
244
+ env.bak/
245
+ venv.bak/
246
+
247
+ # Spyder project settings
248
+ .spyderproject
249
+ .spyproject
250
+
251
+ # Rope project settings
252
+ .ropeproject
253
+
254
+ # mkdocs documentation
255
+ /site
256
+
257
+ # mypy
258
+ .mypy_cache/
259
+ .dmypy.json
260
+ dmypy.json
261
+
262
+ # Pyre type checker
263
+ .pyre/
264
+
265
+ # pytype static type analyzer
266
+ .pytype/
267
+
268
+ # Cython debug symbols
269
+ cython_debug/
270
+
271
+ # PyCharm
272
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
273
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
274
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
275
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
276
+ #.idea/
277
+
278
+ ### Python Patch ###
279
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
280
+ poetry.toml
281
+
282
+ # ruff
283
+ .ruff_cache/
284
+
285
+ # LSP config files
286
+ pyrightconfig.json
287
+
288
+ ### VisualStudioCode ###
289
+ .vscode/*
290
+ !.vscode/settings.json
291
+ !.vscode/tasks.json
292
+ !.vscode/launch.json
293
+ !.vscode/extensions.json
294
+ !.vscode/*.code-snippets
295
+
296
+ # Local History for Visual Studio Code
297
+ .history/
298
+
299
+ # Built Visual Studio Code Extensions
300
+ *.vsix
301
+
302
+ ### VisualStudioCode Patch ###
303
+ # Ignore all local history of files
304
+ .history
305
+ .ionide
306
+ test.py
307
+ models.py
308
+ # local virtualenvs / tooling
309
+ .venv*/
310
+ .hypothesis/
311
+
312
+ # test models are source code
313
+ !tests/models.py
314
+ !docs/examples/shop_models.py
aggify-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.5
2
+ Name: aggify
3
+ Version: 1.0.0
4
+ Summary: Async-first MongoDB ODM with a Django-style API: QuerySets, aggregation pipelines, FastAPI/gRPC/Django integrations.
5
+ Project-URL: Homepage, https://github.com/Aggify/aggify
6
+ Project-URL: Documentation, https://aggify.github.io/aggify
7
+ Project-URL: Issues, https://github.com/Aggify/aggify/issues
8
+ Author-email: "SeYeD.Dev" <me@seyed.dev>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2023 SeYeD
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: aggregation,async,django,fastapi,mongodb,odm,orm,pymongo
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Framework :: AsyncIO
34
+ Classifier: Framework :: Django
35
+ Classifier: Framework :: FastAPI
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Topic :: Database
39
+ Classifier: Typing :: Typed
40
+ Requires-Python: >=3.9
41
+ Requires-Dist: pymongo<5,>=4.13
42
+ Provides-Extra: all
43
+ Requires-Dist: django>=4.2; extra == 'all'
44
+ Requires-Dist: fastapi>=0.110; extra == 'all'
45
+ Requires-Dist: grpcio>=1.60; extra == 'all'
46
+ Requires-Dist: protobuf>=4.25; extra == 'all'
47
+ Requires-Dist: pydantic>=2.5; extra == 'all'
48
+ Provides-Extra: django
49
+ Requires-Dist: django>=4.2; extra == 'django'
50
+ Provides-Extra: fastapi
51
+ Requires-Dist: fastapi>=0.110; extra == 'fastapi'
52
+ Requires-Dist: pydantic>=2.5; extra == 'fastapi'
53
+ Provides-Extra: grpc
54
+ Requires-Dist: grpcio>=1.60; extra == 'grpc'
55
+ Requires-Dist: protobuf>=4.25; extra == 'grpc'
56
+ Provides-Extra: pydantic
57
+ Requires-Dist: pydantic>=2.5; extra == 'pydantic'
58
+ Description-Content-Type: text/markdown
59
+
60
+ <p align="center">
61
+ <img src="https://i.imgur.com/BBp9vUQ.png" alt="Aggify">
62
+ </p>
63
+ <p align="center">
64
+ <em>Async-first MongoDB ODM with a Django-style API - for Django, FastAPI, gRPC and plain Python</em>
65
+ </p>
66
+
67
+ [![Package version](https://img.shields.io/pypi/v/aggify?color=%2334D058&label=pypi%20package)](https://pypi.org/project/aggify)
68
+ [![Downloads](https://img.shields.io/pypi/dm/aggify)](https://pypi.org/project/aggify)
69
+ [![Supported Python versions](https://img.shields.io/pypi/pyversions/aggify.svg?color=%2334D058)](https://pypi.org/project/aggify)
70
+ [![Coverage](https://img.shields.io/codecov/c/github/Aggify/aggify)](https://app.codecov.io/gh/Aggify/aggify)
71
+ [![License](https://img.shields.io/github/license/Aggify/aggify.svg)](https://github.com/Aggify/aggify/blob/main/LICENSE)
72
+ [![Telegram](https://img.shields.io/badge/-telegram-red?color=white&logo=telegram&logoColor=blue)](https://t.me/Aggify)
73
+
74
+ **Aggify 1.0** is a complete rewrite: no MongoEngine, native `async`/`await` on pymongo's `AsyncMongoClient`, an API
75
+ you already know from the Django ORM, and aggregation pipelines that fit on one line.
76
+
77
+ ```python
78
+ import aggify
79
+ from aggify import Document, StringField, DecimalField, ReferenceField, Sum, Count
80
+
81
+ aggify.connect("mongodb://localhost:27017/shop")
82
+
83
+ class Customer(Document):
84
+ name = StringField(required=True)
85
+ country = StringField(max_length=2)
86
+
87
+ class Order(Document):
88
+ customer = ReferenceField(Customer)
89
+ status = StringField(choices=["new", "paid"], default="new")
90
+ total = DecimalField()
91
+
92
+ best = await (
93
+ Order.objects.filter(status="paid", customer__country="DE") # $lookup + $unwind + $match
94
+ .values("customer__name")
95
+ .annotate(revenue=Sum("total"), orders=Count()) # $group
96
+ .filter(orders__gte=3) # HAVING
97
+ .order_by("-revenue")[:10] # $sort + $limit
98
+ .alist()
99
+ )
100
+ ```
101
+
102
+ ## Highlights
103
+
104
+ * **Sync *and* async** - every I/O method has an `a`-twin (`aget`, `alist`, `asave`, `acount`, `aupdate`, ...);
105
+ one async client per event loop, so it is safe in FastAPI, `grpc.aio`, Django's `async_to_sync` and pytest-asyncio.
106
+ * **Django-style** - `Model.objects`, `Q`, `F`, `annotate`, `aggregate`, `values`, `select_related`, `get_or_create`,
107
+ signals, managers, `DoesNotExist`, pagination-ready querysets.
108
+ * **Complex queries, short** - automatic joins (`owner__country="DE"`), `values().annotate()` grouping, conditional
109
+ aggregates (`Sum("x", filter=Q(...))`), window functions, `$facet`, `$bucket`, `$graphLookup`, sub-pipeline
110
+ `$lookup`, array operators, atomic expression updates. See the [cookbook](docs/cookbook.md).
111
+ * **Framework-agnostic integrations** - `pip install "aggify[fastapi|grpc|django|pydantic]"`. Pydantic schemas from
112
+ documents, FastAPI lifespan/errors/pagination, gRPC status mapping, Django app/forms/shortcuts/middleware, and an
113
+ `ObjectIdField` to link Django ORM models to Mongo documents.
114
+ * **Secure by default** - typed fields stop operator injection (`{"$ne": ""}`), regex lookups are escaped,
115
+ server-side JavaScript is blocked, field names validated, strict constructors, resource limits, masked credentials.
116
+ * **Efficient** - `save()` sends only changed fields, optional optimistic locking, `only()/defer()/values()`,
117
+ streaming iterators, bulk operations.
118
+ * **Well tested** - 470+ tests: unit, integration against a real replica set, differential property tests
119
+ (random `Q` trees vs. a Python reference), FastAPI/gRPC/Django end-to-end tests, Python 3.9-3.13.
120
+
121
+ ## Install
122
+
123
+ ```bash
124
+ pip install aggify # core (pymongo >= 4.13)
125
+ pip install "aggify[fastapi]" # + pydantic / fastapi helpers
126
+ pip install "aggify[django]" "aggify[grpc]" "aggify[all]"
127
+ ```
128
+
129
+ ## A tour
130
+
131
+ ```python
132
+ # models: typed fields, embedded documents, references, indexes
133
+ class Account(Document):
134
+ username = StringField(required=True, unique=True)
135
+ tags = ListField(StringField())
136
+ address = EmbeddedField(Address)
137
+ created_at = DateTimeField(auto_now_add=True)
138
+ class Meta:
139
+ ordering = ["username"]
140
+ indexes = [Index("tags")]
141
+
142
+ # CRUD - only changed fields are written
143
+ acc = await Account.objects.acreate(username="ali", tags=["vip"])
144
+ acc.address = Address(city="Tehran")
145
+ await acc.asave() # {"$set": {"address": {...}}}
146
+
147
+ # querying
148
+ Account.objects.filter(Q(tags="vip") | Q(address__city__istartswith="te"), ~Q(banned=True))
149
+ Account.objects.filter(age__gt=F("score") * 10).only("username")[:20]
150
+
151
+ # atomic updates, including server-side expressions
152
+ Account.objects.filter(pk=acc.pk).update(inc__logins=1, push__tags="beta")
153
+ Product.objects.update(price=Round(F("price") * Value(1.1), 2))
154
+
155
+ # transactions (replica set)
156
+ async with aggify.atransaction():
157
+ await Order.objects.acreate(...)
158
+ await Product.objects.filter(pk=pid).aupdate(inc__stock=-1)
159
+
160
+ # the compiled query is always inspectable
161
+ Account.objects.filter(address__city="Tehran").query
162
+ ```
163
+
164
+ Need a stage a queryset does not have? The immutable pipeline builder is one call away:
165
+
166
+ ```python
167
+ from aggify import Aggify
168
+ Aggify(Order).filter(status="paid").facet(
169
+ by_country=Aggify(Order).group("customer__country", n=Count()),
170
+ page=[{"$limit": 20}],
171
+ ).execute()
172
+ ```
173
+
174
+ ## Documentation
175
+
176
+ Full documentation lives in [`docs/`](docs/index.md) (build with `make docs`):
177
+ [quickstart](docs/quickstart.md) - [models](docs/models.md) - [querying](docs/querying.md) -
178
+ [pipelines](docs/aggregation.md) - [cookbook](docs/cookbook.md) - [security](docs/security.md) -
179
+ [testing](docs/testing.md) - [Django](docs/integrations/django.md) - [FastAPI](docs/integrations/fastapi.md) -
180
+ [gRPC](docs/integrations/grpc.md) - [MongoEngine migration](docs/migration/mongoengine.md) -
181
+ [upgrading from 0.x](docs/migration/aggify-0.md) - [فارسی](docs/fa.md).
182
+
183
+ ## Development
184
+
185
+ ```bash
186
+ make install && make mongo && make test # needs Docker for the throw-away MongoDB replica set
187
+ ```
188
+
189
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).
aggify-1.0.0/README.md ADDED
@@ -0,0 +1,130 @@
1
+ <p align="center">
2
+ <img src="https://i.imgur.com/BBp9vUQ.png" alt="Aggify">
3
+ </p>
4
+ <p align="center">
5
+ <em>Async-first MongoDB ODM with a Django-style API - for Django, FastAPI, gRPC and plain Python</em>
6
+ </p>
7
+
8
+ [![Package version](https://img.shields.io/pypi/v/aggify?color=%2334D058&label=pypi%20package)](https://pypi.org/project/aggify)
9
+ [![Downloads](https://img.shields.io/pypi/dm/aggify)](https://pypi.org/project/aggify)
10
+ [![Supported Python versions](https://img.shields.io/pypi/pyversions/aggify.svg?color=%2334D058)](https://pypi.org/project/aggify)
11
+ [![Coverage](https://img.shields.io/codecov/c/github/Aggify/aggify)](https://app.codecov.io/gh/Aggify/aggify)
12
+ [![License](https://img.shields.io/github/license/Aggify/aggify.svg)](https://github.com/Aggify/aggify/blob/main/LICENSE)
13
+ [![Telegram](https://img.shields.io/badge/-telegram-red?color=white&logo=telegram&logoColor=blue)](https://t.me/Aggify)
14
+
15
+ **Aggify 1.0** is a complete rewrite: no MongoEngine, native `async`/`await` on pymongo's `AsyncMongoClient`, an API
16
+ you already know from the Django ORM, and aggregation pipelines that fit on one line.
17
+
18
+ ```python
19
+ import aggify
20
+ from aggify import Document, StringField, DecimalField, ReferenceField, Sum, Count
21
+
22
+ aggify.connect("mongodb://localhost:27017/shop")
23
+
24
+ class Customer(Document):
25
+ name = StringField(required=True)
26
+ country = StringField(max_length=2)
27
+
28
+ class Order(Document):
29
+ customer = ReferenceField(Customer)
30
+ status = StringField(choices=["new", "paid"], default="new")
31
+ total = DecimalField()
32
+
33
+ best = await (
34
+ Order.objects.filter(status="paid", customer__country="DE") # $lookup + $unwind + $match
35
+ .values("customer__name")
36
+ .annotate(revenue=Sum("total"), orders=Count()) # $group
37
+ .filter(orders__gte=3) # HAVING
38
+ .order_by("-revenue")[:10] # $sort + $limit
39
+ .alist()
40
+ )
41
+ ```
42
+
43
+ ## Highlights
44
+
45
+ * **Sync *and* async** - every I/O method has an `a`-twin (`aget`, `alist`, `asave`, `acount`, `aupdate`, ...);
46
+ one async client per event loop, so it is safe in FastAPI, `grpc.aio`, Django's `async_to_sync` and pytest-asyncio.
47
+ * **Django-style** - `Model.objects`, `Q`, `F`, `annotate`, `aggregate`, `values`, `select_related`, `get_or_create`,
48
+ signals, managers, `DoesNotExist`, pagination-ready querysets.
49
+ * **Complex queries, short** - automatic joins (`owner__country="DE"`), `values().annotate()` grouping, conditional
50
+ aggregates (`Sum("x", filter=Q(...))`), window functions, `$facet`, `$bucket`, `$graphLookup`, sub-pipeline
51
+ `$lookup`, array operators, atomic expression updates. See the [cookbook](docs/cookbook.md).
52
+ * **Framework-agnostic integrations** - `pip install "aggify[fastapi|grpc|django|pydantic]"`. Pydantic schemas from
53
+ documents, FastAPI lifespan/errors/pagination, gRPC status mapping, Django app/forms/shortcuts/middleware, and an
54
+ `ObjectIdField` to link Django ORM models to Mongo documents.
55
+ * **Secure by default** - typed fields stop operator injection (`{"$ne": ""}`), regex lookups are escaped,
56
+ server-side JavaScript is blocked, field names validated, strict constructors, resource limits, masked credentials.
57
+ * **Efficient** - `save()` sends only changed fields, optional optimistic locking, `only()/defer()/values()`,
58
+ streaming iterators, bulk operations.
59
+ * **Well tested** - 470+ tests: unit, integration against a real replica set, differential property tests
60
+ (random `Q` trees vs. a Python reference), FastAPI/gRPC/Django end-to-end tests, Python 3.9-3.13.
61
+
62
+ ## Install
63
+
64
+ ```bash
65
+ pip install aggify # core (pymongo >= 4.13)
66
+ pip install "aggify[fastapi]" # + pydantic / fastapi helpers
67
+ pip install "aggify[django]" "aggify[grpc]" "aggify[all]"
68
+ ```
69
+
70
+ ## A tour
71
+
72
+ ```python
73
+ # models: typed fields, embedded documents, references, indexes
74
+ class Account(Document):
75
+ username = StringField(required=True, unique=True)
76
+ tags = ListField(StringField())
77
+ address = EmbeddedField(Address)
78
+ created_at = DateTimeField(auto_now_add=True)
79
+ class Meta:
80
+ ordering = ["username"]
81
+ indexes = [Index("tags")]
82
+
83
+ # CRUD - only changed fields are written
84
+ acc = await Account.objects.acreate(username="ali", tags=["vip"])
85
+ acc.address = Address(city="Tehran")
86
+ await acc.asave() # {"$set": {"address": {...}}}
87
+
88
+ # querying
89
+ Account.objects.filter(Q(tags="vip") | Q(address__city__istartswith="te"), ~Q(banned=True))
90
+ Account.objects.filter(age__gt=F("score") * 10).only("username")[:20]
91
+
92
+ # atomic updates, including server-side expressions
93
+ Account.objects.filter(pk=acc.pk).update(inc__logins=1, push__tags="beta")
94
+ Product.objects.update(price=Round(F("price") * Value(1.1), 2))
95
+
96
+ # transactions (replica set)
97
+ async with aggify.atransaction():
98
+ await Order.objects.acreate(...)
99
+ await Product.objects.filter(pk=pid).aupdate(inc__stock=-1)
100
+
101
+ # the compiled query is always inspectable
102
+ Account.objects.filter(address__city="Tehran").query
103
+ ```
104
+
105
+ Need a stage a queryset does not have? The immutable pipeline builder is one call away:
106
+
107
+ ```python
108
+ from aggify import Aggify
109
+ Aggify(Order).filter(status="paid").facet(
110
+ by_country=Aggify(Order).group("customer__country", n=Count()),
111
+ page=[{"$limit": 20}],
112
+ ).execute()
113
+ ```
114
+
115
+ ## Documentation
116
+
117
+ Full documentation lives in [`docs/`](docs/index.md) (build with `make docs`):
118
+ [quickstart](docs/quickstart.md) - [models](docs/models.md) - [querying](docs/querying.md) -
119
+ [pipelines](docs/aggregation.md) - [cookbook](docs/cookbook.md) - [security](docs/security.md) -
120
+ [testing](docs/testing.md) - [Django](docs/integrations/django.md) - [FastAPI](docs/integrations/fastapi.md) -
121
+ [gRPC](docs/integrations/grpc.md) - [MongoEngine migration](docs/migration/mongoengine.md) -
122
+ [upgrading from 0.x](docs/migration/aggify-0.md) - [فارسی](docs/fa.md).
123
+
124
+ ## Development
125
+
126
+ ```bash
127
+ make install && make mongo && make test # needs Docker for the throw-away MongoDB replica set
128
+ ```
129
+
130
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).
@@ -0,0 +1,48 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Security Issue
4
+
5
+ At Aggify, we take security seriously. We appreciate your help in identifying and addressing security issues. To report a security issue, please follow the guidelines below:
6
+
7
+ **DO NOT** create a public GitHub issue for security-related problems.
8
+
9
+ Instead, please email us directly at [support@aggify.org](mailto:support@aggify.org) with the following information:
10
+
11
+ 1. A detailed description of the security issue, including any potential impact.
12
+ 2. Steps to reproduce the issue or a proof-of-concept if applicable.
13
+ 3. Any additional details that can help us understand and address the problem.
14
+
15
+ We will respond to your report as soon as possible and, if necessary, provide a timeline for a fix. We greatly appreciate responsible disclosure.
16
+
17
+ ## Supported Versions
18
+
19
+ Aggify's security policy applies to the most recent stable release and the previous release. We encourage users to always keep their installations up to date with the latest version.
20
+
21
+ | Version | Supported |
22
+ | ------- | ------------------ |
23
+ | 1.0.x | :white_check_mark: |
24
+ | 0.x | :x: (superseded by the 1.0 rewrite - please upgrade) |
25
+
26
+ ## Security Updates
27
+
28
+ We are committed to addressing security issues promptly. In the event of a confirmed security vulnerability, we will:
29
+
30
+ - Acknowledge receipt of the report within 48 hours.
31
+ - Investigate and verify the reported issue.
32
+ - Develop and test a fix.
33
+ - Release a security update.
34
+ - Credit the individual or organization that reported the vulnerability.
35
+
36
+ ## Contact
37
+
38
+ If you have any questions or concerns regarding the security of Aggify, please contact us at [support@aggify.org](mailto:support@aggify.org). Our team will be happy to assist you.
39
+
40
+ Thank you for helping us make Aggify more secure.
41
+
42
+
43
+ ## Threat model and built-in protections
44
+
45
+ Aggify's protections (operator-injection prevention, regex escaping, JavaScript blocking, validated field names, resource
46
+ limits, credential masking) and what remains the application's responsibility are documented in
47
+ [docs/security.md](docs/security.md). Reports that bypass any of them - for example a value that reaches a query with
48
+ a `$` operator without going through `Raw()` - are treated as vulnerabilities.