storage

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedDatabase = errors.New("unsupported database schema")

Functions

This section is empty.

Types

type ClosableStorage

type ClosableStorage interface {
	io.Closer
	Store(ctx context.Context, table string, fields map[string]any) (map[string]any, error)
}

func NopCloser

func NopCloser(storage interface {
	Store(ctx context.Context, table string, fields map[string]any) (map[string]any, error)
}) ClosableStorage

type DBStore

type DBStore interface {
	ClosableStorage
	Exec(ctx context.Context, query string) error
	Migrate(ctx context.Context, sourceDir string) error
}

func NewDB

func NewDB(ctx context.Context, dialect string, dbURL string) (DBStore, error)

type Dump added in v0.4.1

type Dump struct{}

Dump store just prints in JSON content of request.

func (*Dump) Store added in v0.4.1

func (sd *Dump) Store(_ context.Context, table string, fields map[string]any) (map[string]any, error)

type FileStore

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

FileStore stores each submission as single file in JSON with ULID + .json as name under directory, equal to table name. It DOES NOT escape table name AT ALL. Result set contains all source fields plus ID (string), equal to filename without extension.

func NewFileStore

func NewFileStore(rootDir string) *FileStore

func (*FileStore) Store

func (fs *FileStore) Store(_ context.Context, table string, fields map[string]any) (map[string]any, error)

Jump to

Keyboard shortcuts

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