datastores

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SqliteSeed

func SqliteSeed(ts *testing.T, name string, fn func(*testing.T, SqlDataStore))

Types

type Cache

type Cache interface {
	Set(key string, value any, ttl time.Duration)
	Get(key string) (any, bool)
	Delete(key string)
}

func NewMemoryCache

func NewMemoryCache() Cache

type DataStore

type DataStore interface {
	Sqlite() SqlDataStore
	MemoryCache() Cache
}

func New

func New(options ...Option) DataStore

type Option

type Option func(*dataStoreContainer)

func WithSqlite

func WithSqlite(input string) Option

type SqlDataStore

type SqlDataStore interface {
	WithContext(ctx context.Context) SqlDataStore
	Ping() error
	RunSql(schema string) error
	CreateDatabase(schema ...string) error
	Get(query string, found any, args ...any) error
	Query(query string, found any, args ...any) error
	QueryOne(query string, found any, args ...any) error
	QueryAll(query string, found any, args ...any) error
	Exec(query string, args ...any) error
	ExecAndReturnID(query string, args ...any) (string, error)
	ExecAndReturnRowsAffected(query string, args ...any) (int64, error)
	BulkInsert(table string, columns []string, rows [][]any) error
	Begin() (SqlDataStore, error)
	Commit() error
	Rollback() error
	Connect() error
}

func NewSqlite

func NewSqlite(address string) SqlDataStore

type SqliteStore

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

func (*SqliteStore) Begin

func (store *SqliteStore) Begin() (SqlDataStore, error)

func (*SqliteStore) BulkInsert

func (store *SqliteStore) BulkInsert(table string, columns []string, rows [][]any) error

func (*SqliteStore) Commit

func (store *SqliteStore) Commit() error

func (*SqliteStore) Connect

func (store *SqliteStore) Connect() error

func (*SqliteStore) CreateDatabase

func (store *SqliteStore) CreateDatabase(schema ...string) error

func (*SqliteStore) Exec

func (store *SqliteStore) Exec(query string, args ...any) error

func (*SqliteStore) ExecAndReturnID

func (store *SqliteStore) ExecAndReturnID(query string, args ...any) (string, error)

func (*SqliteStore) ExecAndReturnRowsAffected

func (store *SqliteStore) ExecAndReturnRowsAffected(query string, args ...any) (int64, error)

func (*SqliteStore) Get

func (store *SqliteStore) Get(query string, found any, args ...any) error

func (*SqliteStore) Ping

func (store *SqliteStore) Ping() error

func (*SqliteStore) Query

func (store *SqliteStore) Query(query string, found any, args ...any) error

func (*SqliteStore) QueryAll

func (store *SqliteStore) QueryAll(query string, found any, args ...any) error

func (*SqliteStore) QueryOne

func (store *SqliteStore) QueryOne(query string, found any, args ...any) error

func (*SqliteStore) Rollback

func (store *SqliteStore) Rollback() error

func (*SqliteStore) RunSql

func (store *SqliteStore) RunSql(sql string) error

func (*SqliteStore) WithContext

func (store *SqliteStore) WithContext(ctx context.Context) SqlDataStore

Jump to

Keyboard shortcuts

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