Skip to main content

Mongo ODM for Python

Project description

MongoMapper

Mongo ODM in Python.

MongoMapper is an easy to use ODM for MongoDB, written on top of Pydantic for data validation. Most importantly, it supports datetime.time out-of-the-box because for some reason not even the official MongoDB library supports it. Do coders hate dates that much?

Install

pip install mongomapper

Quick start

Schemas

# examples/schemas.py
from mongomapper import Schema

class User(Schema):
  __collection_name__ = 'users'

  name: str

doc = User.create(name="John")

print(doc.data)

References

# examples/references.py
from mongomapper import Schema, Reference

class Person(Schema):
  __collection_name__ = 'people'

  name: str

class Phone(Schema):
  __collection_name__ = 'phones'

  owner: Reference(Person)

person = Person.create(name="John")
phone = Phone.create(owner=person)

print(person.data)
print(phone.data)

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

mongomapper-1.2.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

mongomapper-1.2.1-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

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