mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-15 11:11:16 +08:00
18 lines
418 B
Python
18 lines
418 B
Python
import motor.motor_asyncio
|
|
from beanie import PydanticObjectId
|
|
from fastapi_users.db import BeanieBaseUser, BeanieUserDatabase
|
|
|
|
DATABASE_URL = "mongodb://localhost:27017"
|
|
client = motor.motor_asyncio.AsyncIOMotorClient(
|
|
DATABASE_URL, uuidRepresentation="standard"
|
|
)
|
|
db = client["database_name"]
|
|
|
|
|
|
class User(BeanieBaseUser[PydanticObjectId]):
|
|
pass
|
|
|
|
|
|
async def get_user_db():
|
|
yield BeanieUserDatabase(User)
|