Model/backend/app/db/functions/materials_functions.py
2023-10-05 17:56:28 +01:00

14 lines
417 B
Python

from backend.app.db.models.materials import Material
from functools import lru_cache
@lru_cache(maxsize=128)
def get_materials(session):
"""
This function will retrieve all materials from the database.
:return: A list of Material objects if successful, an empty list otherwise.
"""
materials = session.query(Material).filter(Material.is_active).all()
return materials if materials else []