Product rendering, cart functionality
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
from typing import Optional
|
||||
|
||||
from db.models import Product
|
||||
@@ -26,3 +26,15 @@ class ProductRepository:
|
||||
result = await session.scalars(stmt)
|
||||
|
||||
return list(result)
|
||||
|
||||
async def add_product_file_id(
|
||||
self, session: AsyncSession, product_id: int, *, file_id: str
|
||||
) -> None:
|
||||
stmt = (
|
||||
update(Product.__table__)
|
||||
.where(Product.id == product_id)
|
||||
.where(Product.file_id is None)
|
||||
.values(file_id=file_id)
|
||||
)
|
||||
await session.execute(stmt)
|
||||
await session.commit()
|
||||
|
||||
Reference in New Issue
Block a user