Documentation
¶
Index ¶
- Variables
- type Sql
- func (s *Sql) Close() error
- func (s *Sql) DeleteCommand(ctx context.Context, id uuid.UUID) error
- func (s *Sql) DeleteExplanation(ctx context.Context, cmdID uuid.UUID) error
- func (s *Sql) DeleteParameters(ctx context.Context, ids []uuid.UUID) error
- func (s *Sql) GetCommandByID(ctx context.Context, id uuid.UUID) (command.Command, error)
- func (s *Sql) GetHistory(ctx context.Context, cmdID uuid.UUID) (command.History, error)
- func (s *Sql) InsertUsage(ctx context.Context, cmdID uuid.UUID, usage string) error
- func (s *Sql) ListCommands(ctx context.Context) ([]command.Command, error)
- func (s *Sql) ReadExplanation(ctx context.Context, cmdID uuid.UUID) (string, error)
- func (s *Sql) Save(ctx context.Context, cmd command.Command) error
- func (s *Sql) SearchCommand(ctx context.Context, term string) ([]command.Command, error)
- func (s *Sql) WriteExplanation(ctx context.Context, cmdID uuid.UUID, explanation string) error
- type SqlOptFunc
Constants ¶
This section is empty.
Variables ¶
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) DeleteCommand ¶
DeleteCommand removes a command and it's params.
func (*Sql) DeleteExplanation ¶
DeleteExplanation removes the explanation of a command.
func (*Sql) DeleteParameters ¶
DeleteParameters removes the parameters with the provided ids.
func (*Sql) GetCommandByID ¶
GetCommandByID returns a command. If the command doesn't exists, returns an ErrNotFound error.
func (*Sql) GetHistory ¶ added in v0.4.0
GetHistory returns the history of usages of a given command.
func (*Sql) InsertUsage ¶ added in v0.4.0
InsertUsage insert the usage of a command.
func (*Sql) ListCommands ¶
ListCommands returns a list of all the commands
func (*Sql) ReadExplanation ¶
ReadExplanation reads the explanation of a command.
func (*Sql) SearchCommand ¶
SearchCommand returns a list of the commands with the matching term.
type SqlOptFunc ¶
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.