Skip to main content

Asynchronous Python ODM for MongoDB

Project description

Beanie

Beanie - is an asynchronous ODM for MongoDB, based on Motor and Pydantic.

It uses an abstraction over Pydantic models and Motor collections to work with the database. Class Document allows to create, replace, update, get, find and aggregate.

Beanie supports migrations out of the box.

Installation

PIP

pip install beanie

Poetry

poetry add beanie

Quick Start

from typing import Optional, List

import motor
from beanie import Document, init_beanie
from pydantic import BaseModel


class Tag(BaseModel):
    name: str
    color: str


class Note(Document):
    title: str
    text: Optional[str]
    tag_list: List[Tag] = []


async def main():
    client = motor.motor_asyncio.AsyncIOMotorClient(
        "mongodb://user:pass@host:27017"
    )
    await init_beanie(database=client.db_name, document_models=[Note])

    all_notes = await Note.find_all().to_list()

Materials

ODM

  • Tutorial - ODM usage examples
  • Documentation - Full list of the ODM classes and methods with descriptions

Migrations

Resources

  • GitHub - GitHub page of the project
  • Changelog - list of all the valuable changes
  • Discord - ask your questions, share ideas or just say Hello!!

Articles

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beanie-0.4.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

beanie-0.4.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file beanie-0.4.0.tar.gz.

File metadata

  • Download URL: beanie-0.4.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/5.8.0-48-generic

File hashes

Hashes for beanie-0.4.0.tar.gz
Algorithm Hash digest
SHA256 cd08f124fd3c073799d89b65ddc313a7713821b56560cd2891ec37347490b5a3
MD5 ab58d886e1c2c1b449b4945598efcf18
BLAKE2b-256 703a6124f93072d1745940252e943d2d6a9dce4f74f8aa2ecce3695200a36515

See more details on using hashes here.

File details

Details for the file beanie-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: beanie-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/5.8.0-48-generic

File hashes

Hashes for beanie-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff495318dfdf4f8929aa6757c3d8891222e04785012903e9ef3d8e0c5949a7af
MD5 5e124fb20632bbec4896b47e6ccc35f7
BLAKE2b-256 01a531b9ca62b7148446d65616976660905f06fd25663c5f055d3a3dd27576ed

See more details on using hashes here.

Supported by

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