mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
* Implement MongoDB adapter using motor * Add mongo container to build pipeline * Tidy up dependencies * Update documentation for MongoDB * Export MongoDB adapter from db package * Pass black format * Update README
15 lines
326 B
Python
15 lines
326 B
Python
import motor.motor_asyncio
|
|
from fastapi import FastAPI
|
|
from fastapi_users.db import MongoDBUserDatabase
|
|
|
|
DATABASE_URL = "mongodb://localhost:27017"
|
|
client = motor.motor_asyncio.AsyncIOMotorClient(DATABASE_URL)
|
|
db = client["database_name"]
|
|
collection = db["users"]
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
user_db = MongoDBUserDatabase(collection)
|