db

package
v0.0.0-...-d9d9782 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateProductParams

type CreateProductParams struct {
	Name  string `json:"name"`
	Price int32  `json:"price"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Product

type Product struct {
	ID        int32     `json:"id"`
	Name      string    `json:"name"`
	Price     int32     `json:"price"`
	CreatedAt time.Time `json:"created_at"`
}

Representação de tabela

type Querier

type Querier interface {
	CreateProduct(ctx context.Context, arg CreateProductParams) (Product, error)
	DeleteProduct(ctx context.Context, id int32) error
	GetProduct(ctx context.Context, id int32) (Product, error)
	GetProducts(ctx context.Context) ([]Product, error)
	UpdateProduct(ctx context.Context, arg UpdateProductParams) (Product, error)
}

Acesso por queries ao banco de dados

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateProduct

func (q *Queries) CreateProduct(ctx context.Context, arg CreateProductParams) (Product, error)

func (*Queries) DeleteProduct

func (q *Queries) DeleteProduct(ctx context.Context, id int32) error

func (*Queries) GetProduct

func (q *Queries) GetProduct(ctx context.Context, id int32) (Product, error)

func (*Queries) GetProducts

func (q *Queries) GetProducts(ctx context.Context) ([]Product, error)

func (*Queries) UpdateProduct

func (q *Queries) UpdateProduct(ctx context.Context, arg UpdateProductParams) (Product, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type StoreExec

type StoreExec struct {
	*Queries
	// contains filtered or unexported fields
}

func NewStoreExec

func NewStoreExec(db *sql.DB) *StoreExec

type UpdateProductParams

type UpdateProductParams struct {
	ID    int32  `json:"id"`
	Name  string `json:"name"`
	Price int32  `json:"price"`
}

Jump to

Keyboard shortcuts

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