fastapi-mongo-base 0.12.3__tar.gz → 0.12.4__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.
- fastapi_mongo_base-0.12.4/MANIFEST.in +1 -0
- {fastapi_mongo_base-0.12.3/src/fastapi_mongo_base.egg-info → fastapi_mongo_base-0.12.4}/PKG-INFO +3 -1
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/pyproject.toml +11 -2
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/models.py +22 -22
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4/src/fastapi_mongo_base.egg-info}/PKG-INFO +3 -1
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base.egg-info/SOURCES.txt +1 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base.egg-info/requires.txt +2 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/LICENSE.txt +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/README.md +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/setup.cfg +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/__init__.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/__init__.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/app_factory.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/config.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/db.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/enums.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/exceptions.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/middlewares.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/timezone.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/routes.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/schemas.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/sql.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/tasks.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/__init__.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/basic.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/bsontools.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/conditions.py +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base.egg-info/dependency_links.txt +0 -0
- {fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include pytest.ini
|
{fastapi_mongo_base-0.12.3/src/fastapi_mongo_base.egg-info → fastapi_mongo_base-0.12.4}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-mongo-base
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.4
|
|
4
4
|
Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
|
|
5
5
|
Author-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
6
6
|
Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
@@ -33,6 +33,8 @@ Requires-Dist: uvicorn[standard]>=0.13.0
|
|
|
33
33
|
Provides-Extra: image
|
|
34
34
|
Requires-Dist: Pillow>=9.0.0; extra == "image"
|
|
35
35
|
Provides-Extra: test
|
|
36
|
+
Requires-Dist: pytest; extra == "test"
|
|
37
|
+
Requires-Dist: mongomock_motor; extra == "test"
|
|
36
38
|
Requires-Dist: coverage; extra == "test"
|
|
37
39
|
Dynamic: license-file
|
|
38
40
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fastapi-mongo-base"
|
|
7
|
-
version = "0.12.
|
|
7
|
+
version = "0.12.4"
|
|
8
8
|
description = "A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -33,7 +33,16 @@ dependencies = [
|
|
|
33
33
|
"fastapi>=0.65.0",
|
|
34
34
|
"uvicorn[standard]>=0.13.0",
|
|
35
35
|
]
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
image = [
|
|
39
|
+
"Pillow>=9.0.0",
|
|
40
|
+
]
|
|
41
|
+
test = [
|
|
42
|
+
"pytest",
|
|
43
|
+
"mongomock_motor",
|
|
44
|
+
"coverage",
|
|
45
|
+
]
|
|
37
46
|
|
|
38
47
|
[project.urls]
|
|
39
48
|
"Homepage" = "https://github.com/mahdikiani/fastapi-mongo-base-app"
|
|
@@ -50,13 +50,13 @@ class BaseEntity(BaseEntitySchema, Document):
|
|
|
50
50
|
@classmethod
|
|
51
51
|
def get_queryset(
|
|
52
52
|
cls,
|
|
53
|
+
*,
|
|
53
54
|
user_id: str | None = None,
|
|
54
55
|
tenant_id: str | None = None,
|
|
55
56
|
is_deleted: bool = False,
|
|
56
57
|
uid: str | None = None,
|
|
57
|
-
*args,
|
|
58
58
|
**kwargs,
|
|
59
|
-
) ->
|
|
59
|
+
) -> dict:
|
|
60
60
|
"""Build a MongoDB query filter based on provided parameters.
|
|
61
61
|
|
|
62
62
|
Args:
|
|
@@ -71,19 +71,19 @@ class BaseEntity(BaseEntitySchema, Document):
|
|
|
71
71
|
List of MongoDB query conditions
|
|
72
72
|
"""
|
|
73
73
|
# Start with basic filters
|
|
74
|
-
base_query =
|
|
74
|
+
base_query = {}
|
|
75
75
|
|
|
76
76
|
# Add standard filters if applicable
|
|
77
|
-
base_query.
|
|
78
|
-
|
|
79
|
-
if hasattr(cls, "user_id") and user_id:
|
|
80
|
-
base_query.append({"user_id": user_id})
|
|
77
|
+
base_query.update({"is_deleted": is_deleted})
|
|
81
78
|
|
|
82
79
|
if hasattr(cls, "tenant_id"):
|
|
83
|
-
base_query.
|
|
80
|
+
base_query.update({"tenant_id": tenant_id})
|
|
81
|
+
|
|
82
|
+
if hasattr(cls, "user_id") and user_id:
|
|
83
|
+
base_query.update({"user_id": user_id})
|
|
84
84
|
|
|
85
85
|
if uid:
|
|
86
|
-
base_query.
|
|
86
|
+
base_query.update({"uid": uid})
|
|
87
87
|
|
|
88
88
|
# Process additional filters from kwargs
|
|
89
89
|
for key, value in kwargs.items():
|
|
@@ -110,29 +110,27 @@ class BaseEntity(BaseEntitySchema, Document):
|
|
|
110
110
|
# Handle range queries and array operators
|
|
111
111
|
if key.endswith("_from") or key.endswith("_to"):
|
|
112
112
|
if basic.is_valid_range_value(value):
|
|
113
|
-
if key.endswith("_from")
|
|
114
|
-
|
|
115
|
-
elif key.endswith("_to"):
|
|
116
|
-
base_query.append({base_field: {"$lte": value}})
|
|
113
|
+
op = "$gte" if key.endswith("_from") else "$lte"
|
|
114
|
+
base_query.setdefault(base_field, {}).update({op: value})
|
|
117
115
|
elif key.endswith("_in") or key.endswith("_nin"):
|
|
118
116
|
value_list = basic.parse_array_parameter(value)
|
|
119
117
|
operator = "$in" if key.endswith("_in") else "$nin"
|
|
120
|
-
base_query.
|
|
118
|
+
base_query.update({base_field: {operator: value_list}})
|
|
121
119
|
else:
|
|
122
|
-
base_query.
|
|
120
|
+
base_query.update({key: value})
|
|
123
121
|
|
|
124
122
|
return base_query
|
|
125
123
|
|
|
126
124
|
@classmethod
|
|
127
125
|
def get_query(
|
|
128
126
|
cls,
|
|
127
|
+
*,
|
|
129
128
|
user_id: str | None = None,
|
|
130
129
|
tenant_id: str | None = None,
|
|
131
130
|
is_deleted: bool = False,
|
|
132
131
|
uid: str | None = None,
|
|
133
132
|
created_at_from: datetime = None,
|
|
134
133
|
created_at_to: datetime = None,
|
|
135
|
-
*args,
|
|
136
134
|
**kwargs,
|
|
137
135
|
) -> FindMany:
|
|
138
136
|
base_query = cls.get_queryset(
|
|
@@ -142,7 +140,6 @@ class BaseEntity(BaseEntitySchema, Document):
|
|
|
142
140
|
uid=uid,
|
|
143
141
|
created_at_from=created_at_from,
|
|
144
142
|
created_at_to=created_at_to,
|
|
145
|
-
*args, # noqa: B026
|
|
146
143
|
**kwargs,
|
|
147
144
|
)
|
|
148
145
|
query = cls.find({"$and": base_query})
|
|
@@ -203,7 +200,6 @@ class BaseEntity(BaseEntitySchema, Document):
|
|
|
203
200
|
user_id=user_id,
|
|
204
201
|
tenant_id=tenant_id,
|
|
205
202
|
is_deleted=is_deleted,
|
|
206
|
-
*args, # noqa: B026
|
|
207
203
|
**kwargs,
|
|
208
204
|
)
|
|
209
205
|
|
|
@@ -307,7 +303,7 @@ class UserOwnedEntity(UserOwnedEntitySchema, BaseEntity):
|
|
|
307
303
|
__abstract__ = True
|
|
308
304
|
|
|
309
305
|
indexes = BaseEntity.Settings.indexes + [
|
|
310
|
-
IndexModel([("user_id", ASCENDING)]),
|
|
306
|
+
IndexModel([("user_id", ASCENDING), ("uid", ASCENDING)]),
|
|
311
307
|
]
|
|
312
308
|
|
|
313
309
|
@classmethod
|
|
@@ -333,7 +329,7 @@ class TenantScopedEntity(TenantScopedEntitySchema, BaseEntity):
|
|
|
333
329
|
__abstract__ = True
|
|
334
330
|
|
|
335
331
|
indexes = BaseEntity.Settings.indexes + [
|
|
336
|
-
IndexModel([("tenant_id", ASCENDING)]),
|
|
332
|
+
IndexModel([("tenant_id", ASCENDING), ("uid", ASCENDING)]),
|
|
337
333
|
]
|
|
338
334
|
|
|
339
335
|
@classmethod
|
|
@@ -361,8 +357,12 @@ class TenantUserEntity(TenantUserEntitySchema, BaseEntity):
|
|
|
361
357
|
class Settings(TenantScopedEntity.Settings):
|
|
362
358
|
__abstract__ = True
|
|
363
359
|
|
|
364
|
-
indexes =
|
|
365
|
-
IndexModel([
|
|
360
|
+
indexes = UserOwnedEntity.Settings.indexes + [
|
|
361
|
+
IndexModel([
|
|
362
|
+
("tenant_id", ASCENDING),
|
|
363
|
+
("user_id", ASCENDING),
|
|
364
|
+
("uid", ASCENDING),
|
|
365
|
+
]),
|
|
366
366
|
]
|
|
367
367
|
|
|
368
368
|
@classmethod
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4/src/fastapi_mongo_base.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-mongo-base
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.4
|
|
4
4
|
Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
|
|
5
5
|
Author-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
6
6
|
Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
@@ -33,6 +33,8 @@ Requires-Dist: uvicorn[standard]>=0.13.0
|
|
|
33
33
|
Provides-Extra: image
|
|
34
34
|
Requires-Dist: Pillow>=9.0.0; extra == "image"
|
|
35
35
|
Provides-Extra: test
|
|
36
|
+
Requires-Dist: pytest; extra == "test"
|
|
37
|
+
Requires-Dist: mongomock_motor; extra == "test"
|
|
36
38
|
Requires-Dist: coverage; extra == "test"
|
|
37
39
|
Dynamic: license-file
|
|
38
40
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/__init__.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/app_factory.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/config.py
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/enums.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/exceptions.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/middlewares.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/core/timezone.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/__init__.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/basic.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/bsontools.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-0.12.3 → fastapi_mongo_base-0.12.4}/src/fastapi_mongo_base/utils/conditions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|