Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

Motor-ODM

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Motor-ODM

A MongoDB ODM based on Motor and Pydantic.

  • 0.1.dev0
  • PyPI
  • Socket score

Maintainers
1

Motor-ODM

Build Documentation Status Codecov Requirements Status PyPI - Python Version PyPI

License Code style: black

A MongoDB ODM based on Motor and Pydantic.

The project code is hosted on GitHub, documentation on ReadTheDocs.

Installation

pip install Motor-ODM

Quick Start

from motor.motor_asyncio import AsyncIOMotorClient
from motor_odm import Document

# Create a custom model by subclassing Document
class User(Document):
    class Mongo:
        # Set the collection name
        collection = "users"

    # Add attributes to your model
    username: str
    age: int

# Connect your model to a database
client = AsyncIOMotorClient(...)
Document.use(client.get_default_database())

# Create documents and save them to the database
u = User(username="John", age=20)
await u.insert()

# Query the database
async for user in User.all():
    print(user.username)

For a more complete overview have a look at the docs.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc