db

package
v0.0.0-...-0d9dc11 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateMessageParams

type CreateMessageParams struct {
	From    string `json:"from"`
	Message string `json:"message"`
}

type CreateMessageTxParams

type CreateMessageTxParams struct {
	CreateMessageParams
}

type CreateMessageTxResult

type CreateMessageTxResult struct {
	Message Message
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type Message

type Message struct {
	ID        int64     `json:"id"`
	From      string    `json:"from"`
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
}

type Querier

type Querier interface {
	CreateMessage(ctx context.Context, arg CreateMessageParams) (Message, error)
	GetMessage(ctx context.Context) (Message, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateMessage

func (q *Queries) CreateMessage(ctx context.Context, arg CreateMessageParams) (Message, error)

func (*Queries) GetMessage

func (q *Queries) GetMessage(ctx context.Context) (Message, error)

func (*Queries) WithTx

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

type SQLStore

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

SQLStore provides all functions to execute SQL queries and transactions

func (*SQLStore) AcquireConn

func (s *SQLStore) AcquireConn(ctx context.Context) (*pgxpool.Conn, error)

func (*SQLStore) CreateMessageTx

func (store *SQLStore) CreateMessageTx(ctx context.Context, arg CreateMessageTxParams) (CreateMessageTxResult, error)

type Store

type Store interface {
	Querier
	AcquireConn(ctx context.Context) (*pgxpool.Conn, error)
	CreateMessageTx(ctx context.Context, arg CreateMessageTxParams) (CreateMessageTxResult, error)
}

Store defines all functions to execute db queries and transactions

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

Jump to

Keyboard shortcuts

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