create_item
Creates a new item in the database by validating the input data, associating it with an owner, and committing the transaction to the session.
def create_item(
session: Session,
item_in: ItemCreate,
owner_id: uuid.UUID
) - > Item
Creates a new item record in the database associated with a specific owner and persists the changes.
Parameters
| Name | Type | Description |
|---|---|---|
| session | Session | The active SQLAlchemy database session used to perform the transaction. |
| item_in | ItemCreate | A Pydantic model containing the initial data and attributes for the new item. |
| owner_id | uuid.UUID | The unique identifier of the user who will own the created item. |
Returns
| Type | Description |
|---|---|
Item | The newly created Item database model instance, refreshed with database-generated fields like IDs or timestamps. |