Use real UUID for User id. and OAuthAccount id. (#198)

* Use UUID for user id and oauth account id

* Update documentation for UUID

* Tweak GUID definition of SQLAlchemy to match Tortoise ORM one

* Write migration doc
This commit is contained in:
François Voron
2020-05-21 16:40:33 +02:00
committed by GitHub
parent df479a9003
commit 0a0dcadfdc
24 changed files with 260 additions and 98 deletions

View File

@@ -12,11 +12,14 @@ Let's create a MongoDB connection and instantiate a collection.
You can choose any name for the database and the collection.
!!! warning
You may have noticed the `uuidRepresentation` parameter. It controls how the UUID values will be encoded in the database. By default, it's set to `pythonLegacy` but new applications should consider setting this to `standard` for cross language compatibility. [Read more about this](https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient).
## Create the database adapter
The database adapter of **FastAPI Users** makes the link between your database configuration and the users logic. Create it like this.
```py hl_lines="32"
```py hl_lines="34"
{!./src/db_mongodb.py!}
```
@@ -26,7 +29,7 @@ Notice that we pass a reference to your [`UserDB` model](../model.md).
The database adapter will automatically create a [unique index](https://docs.mongodb.com/manual/core/index-unique/) on `id` and `email`.
!!! warning
**FastAPI Users** will use its defined [`id` UUID-string](../model.md) as unique identifier for the user, rather than the builtin MongoDB `_id`.
**FastAPI Users** will use its defined [`id` UUID](../model.md) as unique identifier for the user, rather than the builtin MongoDB `_id`.
## Next steps