class Laspatule::Repositories::DB::Ingredients

Included Modules

Defined in:

laspatule/repositories/db/ingredients.cr

Constructors

Instance Method Summary

Instance methods inherited from module Laspatule::Repositories::Ingredients

create(ingredient : Models::CreateIngredient) : Int32 create, get_by_id(id : Int32) : Models::Ingredient get_by_id, search_by_name(name : String, page_size : Int32, next_page previous_page : String | Nil = nil) : Models::Page(Models::Ingredient) search_by_name

Constructor Detail

def self.new(db : ::DB::Database) #

[View source]

Instance Method Detail

def create(ingredient : Models::CreateIngredient) : Int32 #
Description copied from module Laspatule::Repositories::Ingredients

Creates a new ingredient and returns its id.

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


[View source]
def get_by_id(id : Int32) : Models::Ingredient #
Description copied from module Laspatule::Repositories::Ingredients

Gets an ingredient by id.

If the ingredient is not found, raises an IngredientNotFoundError.


[View source]
def search_by_name(name : String, page_size : Int32, next_page previous_page : String | Nil = nil) : Models::Page(Models::Ingredient) #
Description copied from module Laspatule::Repositories::Ingredients

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.


[View source]