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: int | PrimaryKey
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
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": {},
}
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.4.0.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file ext-mongo-0.4.0.tar.gz
.
File metadata
- Download URL: ext-mongo-0.4.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25546898671af15c50e7585c7ffc9f4bc0c4946cb556149c34438199b13765df |
|
MD5 | 2bc40a21891d94d58b7c6db863d89690 |
|
BLAKE2b-256 | a7e67c804c5311f10eabd109db62e35f4baf2766dfe4f7307efcc2f218945e2b |
File details
Details for the file ext_mongo-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: ext_mongo-0.4.0-py3-none-any.whl
- Upload date:
- Size: 3.4 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 | 0e1cb2c1d2c242f2387bdb3402c13d5b8755002c9a14b8217e756f9578116cb8 |
|
MD5 | a1cc37b46e4168e64176d5ec87a1c9cc |
|
BLAKE2b-256 | 6a8839c4f47a90817a4ff55460d0169b9dc9d5c477d9c31f0a00fa10761b125e |