Skip to content

Commit 92b757f

Browse files
committed
♻️ Create Item from all fields in Pydantic model
1 parent bece399 commit 92b757f

File tree

1 file changed

+2
-1
lines changed
  • {{cookiecutter.project_slug}}/backend/app/app/crud

1 file changed

+2
-1
lines changed

{{cookiecutter.project_slug}}/backend/app/app/crud/item.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def get_multi_by_owner(
2828

2929

3030
def create(db_session: Session, *, item_in: ItemCreate, owner_id: int) -> Item:
31-
item = Item(title=item_in.title, description=item_in.description, owner_id=owner_id)
31+
item_in_data = jsonable_encoder(item_in)
32+
item = Item(**item_in_data, owner_id=owner_id)
3233
db_session.add(item)
3334
db_session.commit()
3435
db_session.refresh(item)

0 commit comments

Comments
 (0)