db

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("error row not found")
)

Functions

This section is empty.

Types

type DB

type DB[T Storable] interface {
	Insert(obj T)
	Update(obj T)
	Delete(key string) T
	Get(key string) (T, error)
	GetAll() ([]T, error)
}

func CreateDB

func CreateDB[T Storable](table string, url string) (DB[T], error)

type Storable

type Storable interface {
	GetPrimaryKey() string
}

type StorableIndex

type StorableIndex interface {
	Storable
	GetSecondaryKey() string
}

type WithIndex

type WithIndex[T StorableIndex] interface {
	DB[T]
	GetBoth(key, secondary string) (T, error)
	GetSecondary(secondary string) ([]T, error)
	DeleteSpecific(key string, secondaryKey string) T
	GetPrimary(key string) ([]T, error)
}

func CreateDBWithIndex

func CreateDBWithIndex[T StorableIndex](table string, url string) (WithIndex[T], error)

Jump to

Keyboard shortcuts

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