mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-07 16:36:45 +08:00
Implement MongoDB database adapter (#29)
* 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
This commit is contained in:
14
docs/src/db_mongodb.py
Normal file
14
docs/src/db_mongodb.py
Normal file
@ -0,0 +1,14 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user