Add doc about custom settings when using Beanie (#1193)

This commit is contained in:
Börge Kiss
2023-04-18 11:09:33 +02:00
committed by GitHub
parent 2e387d80ea
commit 0f4cf0c694
2 changed files with 5 additions and 0 deletions

View File

@ -57,6 +57,8 @@ We'll expand from the basic Beanie configuration.
Don't forget to add the `AccessToken` ODM model to the `document_models` array in your Beanie initialization, [just like you did with the `User` model](../../databases/beanie.md#initialize-beanie)!
!!! info
If you want to add your own custom settings to your `AccessToken` document model - like changing the collection name - don't forget to let your inner `Settings` class inherit the pre-defined settings from `BeanieBaseAccessToken` like this: `Settings(BeanieBaseAccessToken.Settings): # ...`! See Beanie's [documentation on `Settings`](https://beanie-odm.dev/tutorial/defining-a-document/#settings) for details.
### Strategy

View File

@ -25,6 +25,9 @@ As you can see, **FastAPI Users** provides a base class that will include base f
!!! info
The base class is configured to automatically create a [unique index](https://roman-right.github.io/beanie/tutorial/defining-a-document/#indexes) on `id` and `email`.
!!! info
If you want to add your own custom settings to your `User` document model - like changing the collection name - don't forget to let your inner `Settings` class inherit the pre-defined settings from `BeanieBaseUser` like this: `class Settings(BeanieBaseUser.Settings): # ...`! See Beanie's [documentation on `Settings`](https://beanie-odm.dev/tutorial/defining-a-document/#settings) for details.
## Create the database adapter
The database adapter of **FastAPI Users** makes the link between your database configuration and the users logic. It should be generated by a FastAPI dependency.