Skip to main content

Async MongoDB ODM with msgspec integration and automatic collection binding

Project description

mongospec

PyPI Python License

Minimal async MongoDB ODM built for speed and simplicity, featuring automatic collection binding and msgspec integration.

Why mongospec?

  • Blazing fast - Uses msgspec (fastest Python serialization) and mongojet (fastest async MongoDB wrapper)
  • 🧩 Dead simple - No complex abstractions, just clean document handling
  • 🏎️ Zero overhead - Optimized for performance-critical applications

Installation

pip install mongospec

Quick Start

import asyncio
from datetime import datetime

import mongojet
import msgspec

import mongospec
from mongospec import MongoDocument


class User(MongoDocument):
    __collection_name__ = "users"
    __indexes__ = [{"keys": [("email", 1)], "options": {"unique": True}}]

    name: str
    email: str
    created_at: datetime = msgspec.field(default_factory=datetime.now)


async def main():
    mongo_client = await mongojet.create_client("mongodb://localhost:27017")
    try:
        await mongospec.init(mongo_client.get_database("db"), document_types=[User])

        # Create and insert user
        user = User(name="Alice", email="alice@example.com")
        await user.insert()

        # Find document
        found = await User.find_one({"email": "alice@example.com"})
        print(found.dump())
    finally:
        await mongospec.close()


asyncio.run(main())

Performance Features

  • 🚀 msgspec-powered serialization (2-10x faster than alternatives)
  • mongojet backend (faster than Motor with identical API)
  • 🧬 Compiled structs for document models
  • 📉 Minimal abstraction overhead

⚠️ Early Alpha Notice
Basic CRUD operations supported. Designed for rapid prototyping. Not production-ready. API will evolve.

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

mongospec-0.0.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mongospec-0.0.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file mongospec-0.0.2.tar.gz.

File metadata

  • Download URL: mongospec-0.0.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for mongospec-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c68a4f34c75a5c0f2133262b366959a67e9d4d451fd21cdc734c10b232bee333
MD5 18ad971dc4d6058ab3d4503c2f9750d8
BLAKE2b-256 a2c1c5a1e4e5da9c830c874f9ab6c175cc3b15703a482c5f9aa6bfa9cb19556a

See more details on using hashes here.

File details

Details for the file mongospec-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mongospec-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for mongospec-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 434df706592f4aba0c58ec44c913a5b37de50b1dfb728b1cd7d540818fffdab8
MD5 3fdfb3ca2a6994b2b8b37d5fd70dce50
BLAKE2b-256 0e62c64595fffcf3f1ab287be6133ade6e85d383a2b3d7aed1cc9343d601264b

See more details on using hashes here.

Supported by

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