Skip to main content

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.2.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

ext_mongo-0.2.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file ext-mongo-0.2.1.tar.gz.

File metadata

  • Download URL: ext-mongo-0.2.1.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

Hashes for ext-mongo-0.2.1.tar.gz
Algorithm Hash digest
SHA256 82f5103bcc3d87acf82cf3658dedc925fb3da5a175d595eee83e6b734d9ed5ba
MD5 267cfdc3d769c3e86e55acc77bbfd001
BLAKE2b-256 8ae2f485279ac9d57e17c7d13ab87edebeb50c352021d8a8349bb7021f4d6a5a

See more details on using hashes here.

File details

Details for the file ext_mongo-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ext_mongo-0.2.1-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

Hashes for ext_mongo-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df8455cb545e03786e266945f01b82e00b11e4c06ec8322dadd0a63eb0663f02
MD5 6f544fa204ad40d66218a87a77e4c221
BLAKE2b-256 650468a5dce0f175c02a645835b1b0ef900c119db8604113604e3c9475575926

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page