db

package
v0.0.0-...-fdf5f90 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Column string
	Op     Operator
	Value  any
}

type DataManipulater

type DataManipulater interface {
	Select(ctx context.Context, table string, columns func() map[string]any, where []Condition) (Result, error)
	Insert(ctx context.Context, table string, rows []map[string]any) (Result, error)
	Update(ctx context.Context, table string, assignments map[string]any, conditions map[string]any) error
	Delete(ctx context.Context, table string, conditions map[string]any) error

	CreateTables(context.Context, []Table) error
	CreateIndexes(context.Context, []Index) error
	CreateViews(context.Context, []View) error
	DropTables(context.Context, []Table) error

	Close() error
}

type Index

type Index struct {
	Name  string
	Table string
	Cols  []string
}

type JSON

type JSON map[string]any

type KVDBer

type KVDBer interface {
	Get(ctx context.Context, key ...string) (map[string][]byte, error)
	Put(ctx context.Context, entries map[string][]byte, ttl time.Duration) error
	Delete(ctx context.Context, key ...string) error
	List(ctx context.Context, prefix *string, limit *uint) ([]string, uint64, error)
	DeleteAll(ctx context.Context) error
	Head(ctx context.Context, key ...string) (bool, error)

	Close() error
}

type Mapper

type Mapper interface {
	CreateTable() []Table
	CreateIndexes() []Index
	CreateViews() []View
}

type Operator

type Operator = uint8
const (
	EQ Operator = iota
	NE
	GE
	GT
	LE
	LT
)

type Result

type Result struct {
	LastID *int64
	Rows   []JSON
}

type Table

type Table struct {
	Name    string   `json:"name"`
	Columns []string `json:"columns"`
}

type View

type View struct {
	Name   string
	Select string
}

Jump to

Keyboard shortcuts

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