mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-07 00:19:10 +08:00
* 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>
35 lines
605 B
Python
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)
|