sqlstorage

package
v0.0.0-...-bb96ada Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonMatchingOrderAndStart = errors.New("OrderBy and StartAfter doesn't have the same number of arguments")

Functions

func NewSQliteClient

func NewSQliteClient(cfg *Config) (*sql.DB, error)

func PaginateSelection

func PaginateSelection(query sq.SelectBuilder, cmd *PaginateCmd) sq.SelectBuilder

Types

type Client

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

func (*Client) Exec

func (c *Client) Exec(query string, args ...any) (sql.Result, error)

func (*Client) ExecContext

func (c *Client) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*Client) Query

func (c *Client) Query(query string, args ...any) (*sql.Rows, error)

func (*Client) QueryContext

func (c *Client) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

func (*Client) QueryRow

func (c *Client) QueryRow(query string, args ...any) *sql.Row

func (*Client) QueryRowContext

func (c *Client) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

type Config

type Config struct {
	Path string `json:"path"`
}

type PaginateCmd

type PaginateCmd struct {
	StartAfter map[string]string
	Limit      int
}

type Querier

type Querier interface {
	Exec(query string, args ...any) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	Query(query string, args ...any) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

func NewSQLQuerier

func NewSQLQuerier(db *sql.DB) Querier

func NewTestStorage

func NewTestStorage(t *testing.T) Querier

type Result

type Result struct {
	fx.Out
	Querier    Querier
	DB         *sql.DB
	Transactor Transactor
}

func Init

func Init(cfg Config, tools tools.Tools) (Result, error)

type RowScanner

type RowScanner interface {
	Scan(...interface{}) error
}

RowScanner is the interface that wraps the Scan method.

Scan behaves like database/sql.Row.Scan.

type SQLTime

type SQLTime time.Time

func (*SQLTime) Scan

func (t *SQLTime) Scan(value any) error

func (SQLTime) Time

func (t SQLTime) Time() time.Time

func (SQLTime) Value

func (t SQLTime) Value() (driver.Value, error)

type TransacService

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

func NewTransacGenerator

func NewTransacGenerator(db *sql.DB, tools tools.Tools) *TransacService

func (*TransacService) WithinTransaction

func (t *TransacService) WithinTransaction(ctx context.Context, tFunc func(ctx context.Context) error) error

WithinTransaction runs function within transaction

The transaction commits when function were finished without error

type Transactor

type Transactor interface {
	// WithinTransaction runs a function within a database transaction.
	//
	// Transaction is propagated in the context,
	// so it is important to propagate it to underlying repositories.
	// Function commits if error is nil, and rollbacks if not.
	// It returns the same error.
	WithinTransaction(context.Context, func(ctx context.Context) error) error
}

Transactor runs logic inside a single database transaction

Jump to

Keyboard shortcuts

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