add products
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
from sqlmodel import Session, select
|
||||
import src.models as models
|
||||
|
||||
def get_all(session: Session) -> list[models.ProductPublic]:
|
||||
def get_all(
|
||||
session: Session,
|
||||
names: list[str],
|
||||
productors: list[str]
|
||||
) -> list[models.ProductPublic]:
|
||||
statement = select(models.Product)
|
||||
if len(names) > 0:
|
||||
statement = statement.where(models.Product.name.in_(names))
|
||||
if len(productors) > 0:
|
||||
statement = statement.join(models.Productor).where(models.Productor.name.in_(productors))
|
||||
return session.exec(statement).all()
|
||||
|
||||
def get_one(session: Session, product_id: int) -> models.ProductPublic:
|
||||
|
||||
Reference in New Issue
Block a user