store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store runs CRUD statements against the exposed tables and views.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRowNotFound = errors.New("row not found")
	ErrNoRowKey    = errors.New("no single-column primary key")
	ErrReadOnly    = errors.New("views are read-only")
	// ErrConflict is a UNIQUE, PRIMARY KEY, or FOREIGN KEY violation.
	ErrConflict = errors.New("conflict")
	// ErrConstraint is a NOT NULL or CHECK violation, or a value of the wrong
	// type for an INTEGER PRIMARY KEY.
	ErrConstraint = errors.New("constraint violation")
)

Functions

This section is empty.

Types

type AllowFunc

type AllowFunc func(table string) bool

type Options

type Options struct {
	MaxPageSize int
	Allow       AllowFunc
}

type Row

type Row = map[string]any

type SQLStore

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

func NewSQLStore

func NewSQLStore(db *sql.DB, introspector schema.Introspector, opts Options) *SQLStore

func (*SQLStore) Delete

func (s *SQLStore) Delete(ctx context.Context, table, pk string) error

func (*SQLStore) Get

func (s *SQLStore) Get(ctx context.Context, table, pk string) (Row, error)

func (*SQLStore) Insert

func (s *SQLStore) Insert(ctx context.Context, table string, row Row) (Row, error)

func (*SQLStore) List

func (s *SQLStore) List(ctx context.Context, table string, req query.ListRequest) ([]Row, error)

func (*SQLStore) Tables

func (s *SQLStore) Tables(ctx context.Context) ([]schema.Table, error)

func (*SQLStore) Update

func (s *SQLStore) Update(ctx context.Context, table, pk string, row Row) (Row, error)

type Store

type Store interface {
	Tables(ctx context.Context) ([]schema.Table, error)
	List(ctx context.Context, table string, req query.ListRequest) ([]Row, error)
	Get(ctx context.Context, table, pk string) (Row, error)
	Insert(ctx context.Context, table string, row Row) (Row, error)
	Update(ctx context.Context, table, pk string, row Row) (Row, error)
	Delete(ctx context.Context, table, pk string) error
}

Jump to

Keyboard shortcuts

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