dao

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConfig

type DBConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
}

type Database

type Database struct {
	Pool *pgxpool.Pool
}

func NewDatabase

func NewDatabase(cfg DBConfig) (*Database, error)

NewDatabase creates a new database connection to PostgreSQL

func (*Database) Close

func (d *Database) Close()

Close closes the database connection pool

type MockRecipeDAO

type MockRecipeDAO struct {
	mock.Mock
}

MockRecipeDAO is an autogenerated mock type for the RecipeDAO type

func NewMockRecipeDAO

func NewMockRecipeDAO(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRecipeDAO

NewMockRecipeDAO creates a new instance of MockRecipeDAO. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRecipeDAO) CreateRecipe

func (_mock *MockRecipeDAO) CreateRecipe(recipe *model.Recipe) error

CreateRecipe provides a mock function for the type MockRecipeDAO

func (*MockRecipeDAO) DeleteRecipe

func (_mock *MockRecipeDAO) DeleteRecipe(id uuid.UUID) error

DeleteRecipe provides a mock function for the type MockRecipeDAO

func (*MockRecipeDAO) EXPECT

func (_m *MockRecipeDAO) EXPECT() *MockRecipeDAO_Expecter

func (*MockRecipeDAO) GetAllRecipes

func (_mock *MockRecipeDAO) GetAllRecipes() ([]*model.Recipe, error)

GetAllRecipes provides a mock function for the type MockRecipeDAO

func (*MockRecipeDAO) GetRecipe

func (_mock *MockRecipeDAO) GetRecipe(id uuid.UUID) (*model.Recipe, error)

GetRecipe provides a mock function for the type MockRecipeDAO

func (*MockRecipeDAO) UpdateRecipe

func (_mock *MockRecipeDAO) UpdateRecipe(recipe *model.Recipe) error

UpdateRecipe provides a mock function for the type MockRecipeDAO

type MockRecipeDAO_CreateRecipe_Call

type MockRecipeDAO_CreateRecipe_Call struct {
	*mock.Call
}

MockRecipeDAO_CreateRecipe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRecipe'

func (*MockRecipeDAO_CreateRecipe_Call) Return

func (*MockRecipeDAO_CreateRecipe_Call) Run

func (*MockRecipeDAO_CreateRecipe_Call) RunAndReturn

type MockRecipeDAO_DeleteRecipe_Call

type MockRecipeDAO_DeleteRecipe_Call struct {
	*mock.Call
}

MockRecipeDAO_DeleteRecipe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRecipe'

func (*MockRecipeDAO_DeleteRecipe_Call) Return

func (*MockRecipeDAO_DeleteRecipe_Call) Run

func (*MockRecipeDAO_DeleteRecipe_Call) RunAndReturn

type MockRecipeDAO_Expecter

type MockRecipeDAO_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockRecipeDAO_Expecter) CreateRecipe

func (_e *MockRecipeDAO_Expecter) CreateRecipe(recipe interface{}) *MockRecipeDAO_CreateRecipe_Call

CreateRecipe is a helper method to define mock.On call

  • recipe *model.Recipe

func (*MockRecipeDAO_Expecter) DeleteRecipe

func (_e *MockRecipeDAO_Expecter) DeleteRecipe(id interface{}) *MockRecipeDAO_DeleteRecipe_Call

DeleteRecipe is a helper method to define mock.On call

  • id uuid.UUID

func (*MockRecipeDAO_Expecter) GetAllRecipes

GetAllRecipes is a helper method to define mock.On call

func (*MockRecipeDAO_Expecter) GetRecipe

func (_e *MockRecipeDAO_Expecter) GetRecipe(id interface{}) *MockRecipeDAO_GetRecipe_Call

GetRecipe is a helper method to define mock.On call

  • id uuid.UUID

func (*MockRecipeDAO_Expecter) UpdateRecipe

func (_e *MockRecipeDAO_Expecter) UpdateRecipe(recipe interface{}) *MockRecipeDAO_UpdateRecipe_Call

UpdateRecipe is a helper method to define mock.On call

  • recipe *model.Recipe

type MockRecipeDAO_GetAllRecipes_Call

type MockRecipeDAO_GetAllRecipes_Call struct {
	*mock.Call
}

MockRecipeDAO_GetAllRecipes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAllRecipes'

func (*MockRecipeDAO_GetAllRecipes_Call) Return

func (*MockRecipeDAO_GetAllRecipes_Call) Run

func (*MockRecipeDAO_GetAllRecipes_Call) RunAndReturn

type MockRecipeDAO_GetRecipe_Call

type MockRecipeDAO_GetRecipe_Call struct {
	*mock.Call
}

MockRecipeDAO_GetRecipe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRecipe'

func (*MockRecipeDAO_GetRecipe_Call) Return

func (*MockRecipeDAO_GetRecipe_Call) Run

func (*MockRecipeDAO_GetRecipe_Call) RunAndReturn

type MockRecipeDAO_UpdateRecipe_Call

type MockRecipeDAO_UpdateRecipe_Call struct {
	*mock.Call
}

MockRecipeDAO_UpdateRecipe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRecipe'

func (*MockRecipeDAO_UpdateRecipe_Call) Return

func (*MockRecipeDAO_UpdateRecipe_Call) Run

func (*MockRecipeDAO_UpdateRecipe_Call) RunAndReturn

type PostgresRecipeDAO

type PostgresRecipeDAO struct {
	// contains filtered or unexported fields
}

func (*PostgresRecipeDAO) CreateRecipe

func (r *PostgresRecipeDAO) CreateRecipe(recipe *model.Recipe) error

CreateRecipe inserts a new recipe with its ingredients and instructions

func (*PostgresRecipeDAO) DeleteRecipe

func (r *PostgresRecipeDAO) DeleteRecipe(id uuid.UUID) error

DeleteRecipe deletes a recipe and its ingredients and instructions

func (*PostgresRecipeDAO) GetAllRecipes

func (r *PostgresRecipeDAO) GetAllRecipes() ([]*model.Recipe, error)

GetAllRecipes retrieves all recipes

func (*PostgresRecipeDAO) GetRecipe

func (r *PostgresRecipeDAO) GetRecipe(id uuid.UUID) (*model.Recipe, error)

GetRecipe retrieves a recipe by ID with its ingredients and instructions

func (*PostgresRecipeDAO) UpdateRecipe

func (r *PostgresRecipeDAO) UpdateRecipe(recipe *model.Recipe) error

UpdateRecipe updates an existing recipe

type RecipeDAO

type RecipeDAO interface {
	CreateRecipe(recipe *model.Recipe) error
	GetRecipe(id uuid.UUID) (*model.Recipe, error)
	GetAllRecipes() ([]*model.Recipe, error)
	UpdateRecipe(recipe *model.Recipe) error
	DeleteRecipe(id uuid.UUID) error
}

func NewRecipeDAO

func NewRecipeDAO(database *Database) RecipeDAO

NewRecipeDAO creates a new recipe DAO

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL