class

Laspatule::Repositories::DB::Ingredients

Inherits Laspatule::Repositories::Ingredients < Reference < Object

Constructors

new(db : ::DB::Database)
Source

Instance methods

create(ingredient : Models::CreateIngredient) : Int32

Creates a new ingredient and returns its id.

If an ingredient with the same name already exists, raises a DuplicatedIngredientError.

Source
get_by_id(id : Int32) : Models::Ingredient

Gets an ingredient by id.

If the ingredient is not found, raises an IngredientNotFoundError.

Source
search_by_name(name : String, page_size : Int32, next_page previous_page : String | Nil = nil) : Models::Page(Models::Ingredient)

Gets an ingredient by name.

Any ingredient containing the given name will be returned. The ingredients are ordered by the size of the name string, shortest first.

This is a paginated query, see Models::Page for pagination instructions.

Source