Skip to content

Releases: Beyotek/MSO-Mongo-Schema-Object-Library

Release v1.0.86

Choose a tag to compare

@github-actions github-actions released this 07 Dec 17:48

MSO v1.0.86

What's Changed

  • Add automatic GitHub Release creation after PyPI publish (43a3c67)
  • Merge Into Master - Release version 1.0.85 (e14de5d)
  • Bump version to 1.0.85 (9db0446)

📦 Installation

pip install MSO==1.0.86

🔗 Links

🚀 Quick Start

from mso import connect_to_mongo, get_model

db = connect_to_mongo("mongodb://localhost:27017", "db-name")
People = get_model(db, "people")

person = People(name="Alice", age=30)
person.save()

1.0.84

Choose a tag to compare

@Beyotek Beyotek released this 07 Dec 17:36

Full Changelog: 1.0.82...1.0.84

1.0.78

Choose a tag to compare

@chuckbeyor101 chuckbeyor101 released this 30 May 14:09
13381ad

🔌 Custom API Endpoints

You can extend the auto-generated API with your own custom routes using the extra_routes parameter in start_api.

➕ Example

from fastapi import APIRouter
from mso.api import start_api

# Connect to MongoDB
client = MongoClient("mongodb://localhost:27017")
db = client["mydb"]

# Define your custom routes
custom_router = APIRouter()

@custom_router.get("/people/stats", tags=["People"])
def get_people_stats():
    return {"message": "Custom stats for the People collection"}

# Start the API with custom routes
start_api(
    db=db,
    collections=["*"],
    extra_routes=custom_router
)

What's Changed

Full Changelog: 1.0.77...1.0.78

1.0.77

Choose a tag to compare

@chuckbeyor101 chuckbeyor101 released this 29 May 22:20
f0f2d28

🚀 New Feature: start_api() – Auto-Generated REST API

MSO now includes a powerful, zero-config API generation utility to expose MongoDB collections as a REST API using FastAPI.

✨ Highlights

  • Instant API: Generate full-featured CRUD endpoints from your MongoDB database schema using:

    from mso.api import start_api start_api(db)
  • Smart Schema Binding: Dynamically binds to collections using MSO's get_model() from your live MongoDB validator schemas.

  • Pagination, Filtering, and Sorting:

    • Flexible query body with filter and sort support

    • ISO date string parsing into proper datetime objects

  • Authentication Support:

    • Pass an auth_func(request) to enforce global or route-specific authentication using FastAPI Depends.

  • Views Supported (Read-only):

    • Automatically detects MongoDB views and limits operations to safe queries.

  • CORS Middleware: Enabled by default with customizable origins, methods, and headers.

 

🔐 Example Authentication Hook

async def my_auth(request: Request): token = request.headers.get("Authorization") if token != "Bearer secret123": raise HTTPException(status_code=403, detail="Unauthorized")

Then pass:

start_api(db, auth_func=my_auth)

🧪 Bonus Features

  • Smart object ID parsing (ObjectId) with error handling

  • Enum-based sorting: accepts "asc" / "desc" or 1 / -1

  • Cleaner OpenAPI documentation with formatted tags

Full Changelog: 1.0.76...1.0.77

1.0.76

Choose a tag to compare

@chuckbeyor101 chuckbeyor101 released this 26 May 17:25
7c51224

What's Changed

  • Update feature to handle read only views for deeply nested objects by @chuckbeyor101 in #11

Full Changelog: 1.0.75...1.0.76

1.0.75

Choose a tag to compare

@chuckbeyor101 chuckbeyor101 released this 26 May 16:52
72ea3f6

What's Changed

Full Changelog: 1.0.74...1.0.75

1.0.74

Choose a tag to compare

@chuckbeyor101 chuckbeyor101 released this 26 May 00:31

Initial release of MSO package to PyPi