def find_by_name(cls, name): return db.session.query(FoodModel).filter( lower(unaccent(FoodModel.name)) == lower(unaccent(name))).first()
def find_foods(cls): return cls.query.order_by(unaccent(FoodModel.name)).all()
def find_brands(cls): return cls.query.order_by(unaccent(BrandModel.name)).all()
def find_chemicals(cls): return cls.query.filter(ChemicalModel.name != 'Nenhum').order_by(unaccent(ChemicalModel.name)).all()
def find_by_brand_food(cls, brand_id, food_id): return cls.query.filter_by(id_brand=brand_id, id_food=food_id).order_by(unaccent(text("name")))
def find_by_brand(cls, brand_id): return cls.query.filter_by(id_brand=brand_id).order_by( unaccent(text("brand_1.name")))
def find_by_food(cls, food_id): return cls.query.filter_by(id_food=food_id).order_by( unaccent(text("food_1.name")))