Exemple #1
0
    def get(self, id):
        query = '''SELECT id, name
                     FROM ingredients
                    WHERE id = %s'''

        ingredient = database.fetch(query, id)

        query = '''SELECT allergies.id, allergies.name
                     FROM allergies
                          INNER JOIN allergies_ingredients
                          ON allergies.id = allergies_ingredients.allergy_id
                   WHERE ingredient_id = %s'''

        ingredient['allergens'] = database.fetch_all(query, id)

        return ingredient
Exemple #2
0
    def get(self, search):
        query = '''SELECT id, name
                     FROM allergies
                    WHERE name LIKE %s'''

        return database.fetch_all(query, f'%{search}%')
Exemple #3
0
    def get(self):
        query = '''SELECT id, name
                     FROM allergies'''

        return database.fetch_all(query)
Exemple #4
0
    def get(self):
        query = '''SELECT id, name
                     FROM ingredients'''

        return database.fetch_all(query)