-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipe.py
37 lines (27 loc) · 941 Bytes
/
recipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from dataclasses import dataclass
import uuid
import peewee
db = peewee.SqliteDatabase("remy.db")
class Recipe(peewee.Model):
name = peewee.CharField()
description = peewee.CharField()
class Meta:
database = db
class Ingredient(peewee.Model):
name = peewee.CharField()
recipe = peewee.ForeignKeyField(Recipe, backref="ingredients", null=True)
units = peewee.CharField()
class Meta:
database = db
class RecipeToIngredient(peewee.Model):
recipe = peewee.ForeignKeyField(Recipe, backref="recipe_to_ingredient")
ingredient = peewee.ForeignKeyField(Ingredient, backref="recipe_to_ingredient")
quantity = peewee.FloatField()
class Meta:
database = db
class RecipeToStep(peewee.Model):
recipe = peewee.ForeignKeyField(Recipe, backref="recipe_to_step")
step = peewee.CharField()
order = peewee.IntegerField() # 1-indexed
class Meta:
database = db