Files
fastapi-users/docs/src/db_mongodb.py
martincolladofab efad0e0fef fix "Swagger issue for endpoints register & update" (#233)
* fix: Change on the inheritance model, according to the documentation for the request body parameters. #171

* fix: Changes on the documentation examples to fix the inheritance problem when passing the User class (for create or update only passing the pydantic one) #171

* fix: Changes on the documentation examples to fix the inheritance problem when passing the User class (for create or update only passing the pydantic one) #171

* Put back inheritance on update model and factorize create_update_dict methods

Co-authored-by: François Voron <fvoron@gmail.com>
2020-06-27 17:19:53 +02:00

35 lines
605 B
Python

import motor.motor_asyncio
from fastapi import FastAPI
from fastapi_users import models
from fastapi_users.db import MongoDBUserDatabase
class User(models.BaseUser):
pass
class UserCreate(models.BaseUserCreate):
pass
class UserUpdate(User, models.BaseUserUpdate):
pass
class UserDB(User, models.BaseUserDB):
pass
DATABASE_URL = "mongodb://localhost:27017"
client = motor.motor_asyncio.AsyncIOMotorClient(
DATABASE_URL, uuidRepresentation="standard"
)
db = client["database_name"]
collection = db["users"]
app = FastAPI()
user_db = MongoDBUserDatabase(UserDB, collection)