Skip to content

How to add new database models that have relationships with User? #539

Answered by frankie567
rbracco asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @rbracco!

What is the difference between UserDB and UserTable?

The UserDB is the model with all the fields that should exist in your database to help you with your logic, but that shouldn't be shown to the end-user. Typically, the hashed_password field. When using the dependency injection, FastAPI Users will always give you the BaseUserDB, so that you have all the data to do what you need.

UserDB is a Pydantic model. This is how FastAPI handle data validation and data serialization.

UserTable is a table definition for SQLAlchemy (https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/basic_use.html#basic-use).

➡️ You should also have Pydantic model for your AudioFile ; it'll grea…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rbracco
Comment options

@frankie567
Comment options

Answer selected by rbracco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants