Extended mongoengine
Project description
Depends on environment variables:
MONGO_DB
(Required)MONGO_HOST
(Optional)MONGO_PASSWORD
(Optional)MONGO_USER
(Default:"root"
)MONGO_PORT
(Optional)
Example:
from datetime import datetime, date
from bson import ObjectId
from mongo import Document, PrimaryKey
class Doc(Document):
key: PrimaryKey[int]
a1: str # Required
a2: int | None
a3: bool | None
a4: float | None
a5: ObjectId | None
a6: datetime | None
a7: date | None
b1: list[str]
b2: list[int]
b3: list[bool]
b4: list[float]
b5: list[ObjectId]
b6: list[datetime]
b7: list[date]
c1: dict
c2: list[dict]
KEY = 0
A1 = "a1"
d = Doc(key=KEY, a1=A1).save()
assert Doc.get(KEY) == d
assert Doc.find(a1=A1) == d
assert Doc.find_all(a1=A1) == [d]
assert d.str_id == str(KEY)
assert d.to_dict() == {
"_id": KEY,
"a1": A1,
"b1": [],
"b2": [],
"b3": [],
"b4": [],
"b5": [],
"b6": [],
"b7": [],
"c1": {},
"c2": [],
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ext-mongo-0.3.0.tar.gz
(2.8 kB
view details)
Built Distribution
File details
Details for the file ext-mongo-0.3.0.tar.gz
.
File metadata
- Download URL: ext-mongo-0.3.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c2cba6a521b8289254c72270b33ac50855901fbcbad73168d499fb6f7ec80c9 |
|
MD5 | 4bb68c52da78303e93942c1928e2b09e |
|
BLAKE2b-256 | 9468e90f996d1f0d3aa4acc9a32b19944e29d9643771296fd5ad767aa56b862a |
File details
Details for the file ext_mongo-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: ext_mongo-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 248becd4f044ba3aa46e9883f9c893b437dcbbbaf87150d79edeebfbdafa08a6 |
|
MD5 | 378efd91392a904ffbd83a48bc0605df |
|
BLAKE2b-256 | 5a71907994545904d919b26f80f794e8efc985a5d3eb9f30cd29ea7072cb30e7 |