All Projects → aminalaee → mongox

aminalaee / mongox

Licence: MIT license
Familiar async Python MongoDB ODM

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to mongox

starlite
Light, Flexible and Extensible ASGI API framework
Stars: ✭ 1,525 (+1249.56%)
Mutual labels:  asgi, starlette, pydantic
spectree
API spec validator and OpenAPI document generator for Python web frameworks.
Stars: ✭ 190 (+68.14%)
Mutual labels:  asgi, starlette, pydantic
pait
Python Modern API Tools, fast to code
Stars: ✭ 24 (-78.76%)
Mutual labels:  starlette, pydantic
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+34933.63%)
Mutual labels:  starlette, pydantic
inboard
🚢 Docker images and utilities to power your Python APIs and help you ship faster. With support for Uvicorn, Gunicorn, Starlette, and FastAPI.
Stars: ✭ 106 (-6.19%)
Mutual labels:  asgi, starlette
morelia server
Server for MoreliaTalk network
Stars: ✭ 25 (-77.88%)
Mutual labels:  starlette, pydantic
async-asgi-testclient
A framework-agnostic library for testing ASGI web applications
Stars: ✭ 123 (+8.85%)
Mutual labels:  asgi, starlette
arel
Lightweight browser hot reload for Python ASGI web apps
Stars: ✭ 69 (-38.94%)
Mutual labels:  asgi, starlette
fastapi-zeit-now
A simple example of deploying FastAPI as a Zeit Serverless Function
Stars: ✭ 24 (-78.76%)
Mutual labels:  asgi, starlette
serverless-mangum-examples
Example ASGI applications and Serverless Framework configurations using Mangum
Stars: ✭ 26 (-76.99%)
Mutual labels:  asgi, starlette
webargs-starlette
Declarative request parsing and validation for Starlette with webargs
Stars: ✭ 36 (-68.14%)
Mutual labels:  asgi, starlette
msgpack-asgi
Drop-in MessagePack support for ASGI applications and frameworks
Stars: ✭ 100 (-11.5%)
Mutual labels:  asgi, starlette
starlette-graphene3
An ASGI app for using Graphene v3 with Starlette / FastAPI
Stars: ✭ 52 (-53.98%)
Mutual labels:  asgi, starlette
XATC
DIY CNC Automatic Toolchanger
Stars: ✭ 47 (-58.41%)
Mutual labels:  motor
lnurl
LNURL implementation for Python.
Stars: ✭ 51 (-54.87%)
Mutual labels:  pydantic
openstage
Arduino-based microscope stage controller
Stars: ✭ 34 (-69.91%)
Mutual labels:  motor
overhave
Web-framework for BDD: scalable, configurable, easy to use, based on Flask Admin and Pydantic.
Stars: ✭ 61 (-46.02%)
Mutual labels:  pydantic
Big Easy Driver
The Big Easy Driver available from SparkFun Electronics
Stars: ✭ 21 (-81.42%)
Mutual labels:  motor
Sanic
Async Python 3.7+ web server/framework | Build fast. Run fast.
Stars: ✭ 15,660 (+13758.41%)
Mutual labels:  asgi
Datasette
An open source multi-tool for exploring and publishing data
Stars: ✭ 5,640 (+4891.15%)
Mutual labels:  asgi

Build Status Publish Status Coverage Package version Supported Python versions


MongoX

MongoX is an async python ODM (Object Document Mapper) for MongoDB which is built on top of Motor and Pydantic.

The main features include:

  • Fully type annotated
  • Async support Python 3.7+ (since it's built on top of Motor)
  • Elegant editor support (since it's built on top of Pydantic)
  • Autocompletion everywhere, from object creation to query results
  • Custom query builder which is more intuitive and pythonic
  • 100% test coverage

MongoX models are at the same time Pydantic models and have the same functionalitties, so you can use them with your existing Pydantic models.


Documentation: https://aminalaee.github.io/mongox


Installation

$ pip install mongox

Quickstart

You can define mongox models the same way you define Pydantic models. The difference is they should inherit from mongox.Model now:

import asyncio

import mongox

client = mongox.Client("mongodb://localhost:27017")
db = client.get_database("test_db")


class Movie(mongox.Model, db=db, collection="movies"):
    name: str
    year: int

Now you can create some instances and insert them into the database:

movie = await Movie(name="Forrest Gump", year=1994).insert()

The returned result will be a Movie instance, and mypy will understand that this is a Movie instance. So you will have type hints and validations everywhere.

Now you can fetch some data from the database.

You can use the same pattern as PyMongo/Motor:

movie = await Movie.query({"name": "Forrest Gump"}).get()

Or you can use Movie fields instead of dictionaries in the query (less room for bugs):

movie = await Movie.query({Movie.name: "Forrest Gump"}).get()

And finally you can use a more intuitive query (limited yet):

movie = await Movie.query(Movie.name == "Forrest Gump").get()

Notice how we omitted the dictionary and passed the Movie fields in comparison.


Please refer to the documentation here or the full examples here.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].