diff options
| author | xengineering <me@xengineering.eu> | 2024-10-24 17:24:00 +0200 | 
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2024-10-24 20:14:14 +0200 | 
| commit | 9422e8194245c9cdbfa09b38c20173964349e2a2 (patch) | |
| tree | b65f6b8682a97f81309022934c0a230d8481c4d3 /model | |
| parent | dc37aaceea903fcc84144c7566a14b3c5378dcaf (diff) | |
| download | ceres-9422e8194245c9cdbfa09b38c20173964349e2a2.tar ceres-9422e8194245c9cdbfa09b38c20173964349e2a2.tar.zst ceres-9422e8194245c9cdbfa09b38c20173964349e2a2.zip | |
view: Order ingredient summary by ingredient name
This makes it easier to write a shopping list for the required
ingredients.
Diffstat (limited to 'model')
| -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") | 
