diff options
Diffstat (limited to 'model/ingredient.go')
-rw-r--r-- | model/ingredient.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/model/ingredient.go b/model/ingredient.go index 9922060..e4570ff 100644 --- a/model/ingredient.go +++ b/model/ingredient.go @@ -45,6 +45,22 @@ func (i *Ingredient) Validate() error { return nil } +func (i Ingredient) String() string { + str := "" + + if i.Amount != "" { + str += i.Amount + " " + } + + if i.Unit != "" { + str += i.Unit + " " + } + + str += i.Type + + return str +} + func (i *Ingredient) Create(tx *sql.Tx) error { if i.Id != "" { return fmt.Errorf("Cannot create ingredient if ID is given") |