sql

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound used when the searched element wasn't found.

Functions

This section is empty.

Types

type Sql

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

Sql store

func NewSql

func NewSql(logger *slog.Logger, opts ...SqlOptFunc) (*Sql, error)

NewSql returns a new SQL store.

func (*Sql) Close

func (s *Sql) Close() error

Close closes the db driver.

func (*Sql) DeleteCommand

func (s *Sql) DeleteCommand(ctx context.Context, id uuid.UUID) error

DeleteCommand removes a command and it's params.

func (*Sql) DeleteExplanation

func (s *Sql) DeleteExplanation(ctx context.Context, cmdID uuid.UUID) error

DeleteExplanation removes the explanation of a command.

func (*Sql) DeleteParameters

func (s *Sql) DeleteParameters(ctx context.Context, ids []uuid.UUID) error

DeleteParameters removes the parameters with the provided ids.

func (*Sql) GetCommandByID

func (s *Sql) GetCommandByID(ctx context.Context, id uuid.UUID) (command.Command, error)

GetCommandByID returns a command. If the command doesn't exists, returns an ErrNotFound error.

func (*Sql) GetHistory added in v0.4.0

func (s *Sql) GetHistory(ctx context.Context, cmdID uuid.UUID) (command.History, error)

GetHistory returns the history of usages of a given command.

func (*Sql) InsertUsage added in v0.4.0

func (s *Sql) InsertUsage(ctx context.Context, cmdID uuid.UUID, usage string) error

InsertUsage insert the usage of a command.

func (*Sql) ListCommands

func (s *Sql) ListCommands(ctx context.Context) ([]command.Command, error)

ListCommands returns a list of all the commands

func (*Sql) ReadExplanation

func (s *Sql) ReadExplanation(ctx context.Context, cmdID uuid.UUID) (string, error)

ReadExplanation reads the explanation of a command.

func (*Sql) Save

func (s *Sql) Save(ctx context.Context, cmd command.Command) error

Save stores a command on the sql store.

func (*Sql) SearchCommand

func (s *Sql) SearchCommand(ctx context.Context, term string) ([]command.Command, error)

SearchCommand returns a list of the commands with the matching term.

func (*Sql) WriteExplanation

func (s *Sql) WriteExplanation(ctx context.Context, cmdID uuid.UUID, explanation string) error

WriteExplanation writes the explanation for a command.

type SqlOptFunc

type SqlOptFunc func(store *Sql) error

SqlOptFunc optional functions for Sql store.

func WithSqliteDriver

func WithSqliteDriver(ctx context.Context, path string) SqlOptFunc

WithSqliteDriver returns a sqlOptFunc that sets the config necessary for a SQLite store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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