diff --git a/docs/docs/06_sql_storage_sqlalchemy/07_updating_models_sqlalchemy/README.md b/docs/docs/06_sql_storage_sqlalchemy/07_updating_models_sqlalchemy/README.md index 91d41933..55ec7991 100644 --- a/docs/docs/06_sql_storage_sqlalchemy/07_updating_models_sqlalchemy/README.md +++ b/docs/docs/06_sql_storage_sqlalchemy/07_updating_models_sqlalchemy/README.md @@ -30,3 +30,24 @@ def put(self, item_data, item_id): return item # highlight-end ``` + +Our `ItemUpdateSchema` at the moment looks like this: + +```python title="schemas.py" +class ItemUpdateSchema(Schema): + name = fields.Str() + price = fields.Float() +``` + +But since now our update endpoint may create items, we need to change the schema to optionally accept a `store_id`. + +When updating an item, `name` or `price` (or both) may be passed, but when creating an item, `name`, `price`, and `store_id` must be passed. + +Update the `ItemUpdateSchema` to this: + +```python title="schemas.py" +class ItemUpdateSchema(Schema): + name = fields.Str() + price = fields.Float() + store_id = fields.Int() +```