Currently, a lot of the tables.py files hold classes that have their own patching and serialization functions (see OfficerTerm in src/officers/tables.py. We should just let Pydantic's built in features handle that since it can handle serialization, patching, and validation. The data flow would look something like:
- GET request -> server
- Fetch the entry/entries from the database as SQL table entries
<Table>DB
- SQL Table model -> (process data) -> Pydantic model created from table model
<Model>(<Table>DB)
For requests that take in data, like POST/PATCH/PUT:
- POST/PATCH/PUT -> server
- [if PATCH/PUT] fetch entries from database -> put in Pydantic model, otherwise create a new Pydantic model
- Use Pydantic's validation method to ensure the updated data is good
- Convert to a SQL Table model and send it to the database
To do this we'd need to:
Currently, a lot of the
tables.pyfiles hold classes that have their own patching and serialization functions (seeOfficerTerminsrc/officers/tables.py. We should just let Pydantic's built in features handle that since it can handle serialization, patching, and validation. The data flow would look something like:<Table>DB<Model>(<Table>DB)For requests that take in data, like POST/PATCH/PUT:
To do this we'd need to: