Documentation ¶
Index ¶
- func Close(ctx context.Context) error
- func ConnectPostgres(c *PostgresConfig) (*sql.DB, error)
- func Delete(ctx context.Context, id int32) (int64, error)
- func Get(ctx context.Context, id int32) (*todolistpb.Todo, error)
- func Insert(ctx context.Context, todo *todolistpb.Todo) (int32, error)
- func List(ctx context.Context) ([]*todolistpb.Todo, error)
- func SetRepository(ctx context.Context, repository Repository) context.Context
- func Setup(c *PostgresConfig) *sql.DB
- func Update(ctx context.Context, todo *todolistpb.Todo) (*todolistpb.Todo, error)
- type MockDB
- func (m *MockDB) Close() error
- func (m *MockDB) Delete(id int32) (int64, error)
- func (m *MockDB) Get(id int32) (*todolistpb.Todo, error)
- func (m *MockDB) Insert(todo *todolistpb.Todo) (int32, error)
- func (m *MockDB) List() ([]*todolistpb.Todo, error)
- func (m *MockDB) Update(todo *todolistpb.Todo) (*todolistpb.Todo, error)
- type Postgres
- func (p *Postgres) Close() error
- func (p *Postgres) Delete(id int32) (int64, error)
- func (p *Postgres) Get(id int32) (*todolistpb.Todo, error)
- func (p *Postgres) Insert(todo *todolistpb.Todo) (int32, error)
- func (p *Postgres) List() ([]*todolistpb.Todo, error)
- func (p *Postgres) Update(todo *todolistpb.Todo) (*todolistpb.Todo, error)
- type PostgresConfig
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectPostgres ¶
func ConnectPostgres(c *PostgresConfig) (*sql.DB, error)
ConnectPostgres is connecting to a Postgres database
func SetRepository ¶
func SetRepository(ctx context.Context, repository Repository) context.Context
SetRepository sets the repository
func Update ¶
func Update(ctx context.Context, todo *todolistpb.Todo) (*todolistpb.Todo, error)
Update is updating the data in the database
Types ¶
type MockDB ¶
type MockDB struct { }
MockDB interface
func (*MockDB) Get ¶
func (m *MockDB) Get(id int32) (*todolistpb.Todo, error)
Get is getting the data from the database
func (*MockDB) Insert ¶
func (m *MockDB) Insert(todo *todolistpb.Todo) (int32, error)
Insert is inserting the data to the database
func (*MockDB) Update ¶
func (m *MockDB) Update(todo *todolistpb.Todo) (*todolistpb.Todo, error)
Update is updating the data in the database
type Postgres ¶
Postgres sql interface
func (*Postgres) Get ¶
func (p *Postgres) Get(id int32) (*todolistpb.Todo, error)
Get is getting the data from the database
func (*Postgres) Insert ¶
func (p *Postgres) Insert(todo *todolistpb.Todo) (int32, error)
Insert is inserting the data to the database
func (*Postgres) List ¶
func (p *Postgres) List() ([]*todolistpb.Todo, error)
List is listing the data
func (*Postgres) Update ¶
func (p *Postgres) Update(todo *todolistpb.Todo) (*todolistpb.Todo, error)
Update is updating the data in the database
type PostgresConfig ¶
PostgresConfig holds the configs
type Repository ¶
type Repository interface { Close() error Insert(*todolistpb.Todo) (int32, error) Get(int32) (*todolistpb.Todo, error) Update(*todolistpb.Todo) (*todolistpb.Todo, error) Delete(int32) (int64, error) List() ([]*todolistpb.Todo, error) }
Repository interface
Click to show internal directories.
Click to hide internal directories.