database

package
v0.0.0-...-d77435e Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBClient

type DBClient struct {
	*sqlx.DB
}

func NewDBClient

func NewDBClient(ctx context.Context, connString string) (*DBClient, error)

const connString = "postgresql://postgres:Password123@localhost:5432/moviesdb?sslmode=disable"

func (*DBClient) Create

func (db *DBClient) Create(ctx context.Context, user User) (User, error)

func (*DBClient) Delete

func (db *DBClient) Delete(ctx context.Context, id int) error

func (*DBClient) GetAll

func (db *DBClient) GetAll(ctx context.Context) ([]User, error)

func (*DBClient) GetByID

func (db *DBClient) GetByID(ctx context.Context, id int64) (User, error)

type User

type User struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type UsersStore

type UsersStore interface {
	GetAll(ctx context.Context) ([]User, error)
	GetByID(ctx context.Context, id int64) (User, error)
	Create(ctx context.Context, user User) (User, error)
	Delete(ctx context.Context, id int) error
}

Jump to

Keyboard shortcuts

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