Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.0.0-...-10a0382 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package store abstracts the database layer behind store.Store methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDefaults

func WithDefaults() []sqlxmod.Opt

func WithMigrations

func WithMigrations() sqlxmod.Opt

func WithOtel

func WithOtel() sqlxmod.Opt

Types

type NamedDB

type NamedDB struct {
	*sqlx.DB
}

NamedDB is a wrapper around sqlx.DB that adds NamedGetContext method. https://github.com/jmoiron/sqlx/issues/154#issuecomment-148216948

func (NamedDB) NamedGetContext

func (n NamedDB) NamedGetContext(ctx context.Context, dest interface{}, query string, arg interface{}) error

NamedGetContext executes a named query with the given context and arguments. It prepares the statement, executes it, and scans the result into the destination. This is commonly used for INSERT ... RETURNING query.

type Store

type Store struct {
	srvc.Module
	// contains filtered or unexported fields
}

Store wraps the sqlxmod module and provides an interface to interact with the database.

func New

func New(opts ...sqlxmod.Opt) *Store

func (*Store) AddTasks

func (s *Store) AddTasks(ctx context.Context, newTask api.NewTask) (*api.Task, error)

func (*Store) DeleteTasks

func (s *Store) DeleteTasks(ctx context.Context, id int64) error

func (*Store) GetTasks

func (s *Store) GetTasks(ctx context.Context) ([]api.Task, error)

func (*Store) Healthy

func (s *Store) Healthy(ctx context.Context) error

Jump to

Keyboard shortcuts

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