Repository navigation
Releases: Beyotek/MSO-Mongo-Schema-Object-Library
Release list
Release v1.0.86
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
1.0.78
🔌 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
- Feature/api custom routes by @chuckbeyor101 in #15
Full Changelog: 1.0.77...1.0.78
1.0.77
🚀 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
datetimeobjects
-
-
Authentication Support:
-
Pass an
auth_func(request)to enforce global or route-specific authentication using FastAPIDepends.
-
-
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"or1/-1 -
Cleaner OpenAPI documentation with formatted tags
Full Changelog: 1.0.76...1.0.77
1.0.76
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
What's Changed
- Add feature to handle read only Mongo DB views by @chuckbeyor101 in #9
Full Changelog: 1.0.74...1.0.75
1.0.74
Initial release of MSO package to PyPi