Documentation
¶
Index ¶
- Variables
- func Delete[T any](del func(v *T) bool) error
- func Find[T any](compare func(v *T) bool, options ...FindOption[T]) ([]T, error)
- func FindAll[T any]() ([]T, error)
- func FindFirst[T any](compare func(v *T) bool) (T, error)
- func Get[T any](key PrimaryKey) (T, error)
- func Insert[T any](v *T) error
- func Register(structs ...any) error
- func Remove[T any](key PrimaryKey) error
- func Set[T any](key PrimaryKey, value *T) error
- func SetDefaultDB(db *Database)
- func Update[T any](update func(v *T) *T) error
- type Database
- type ExtendedModel
- type FindOption
- type GobStorage
- type Model
- type PrimaryKey
- type Serialized
- type SerializedTable
- type Storage
- type Table
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDuplicatePrimaryKey = errors.New("duplicate primary key")
View Source
var ErrMultiplePrimaryKeys = errors.New("type has multiple exported primary key fields")
View Source
var ErrNoPrimaryKey = errors.New("type does not have an exported primary key field")
View Source
var ErrRowNotFound = errors.New("row not found")
View Source
var ErrTableExists = errors.New("table already exists")
View Source
var ErrTableNotExists = errors.New("table does not exist")
View Source
var ErrTypeIsNotStruct = errors.New("type is not a struct")
View Source
var ErrUnaddressableValue = errors.New("value is unaddressable")
Functions ¶
func Get ¶
func Get[T any](key PrimaryKey) (T, error)
func Remove ¶
func Remove[T any](key PrimaryKey) error
func Set ¶
func Set[T any](key PrimaryKey, value *T) error
func SetDefaultDB ¶
func SetDefaultDB(db *Database)
Types ¶
type ExtendedModel ¶
func (ExtendedModel) Default ¶
func (m ExtendedModel) Default() any
type FindOption ¶
type FindOption[T any] func([]T) []T
func Limit ¶
func Limit[T any](n int) FindOption[T]
func Skip ¶
func Skip[T any](n int) FindOption[T]
func Sort ¶
func Sort[T any](compare func(T, T) int) FindOption[T]
type GobStorage ¶
type GobStorage struct {
// contains filtered or unexported fields
}
func NewGobStorage ¶
func NewGobStorage(source string) *GobStorage
func (*GobStorage) Load ¶
func (s *GobStorage) Load() error
func (*GobStorage) Save ¶
func (s *GobStorage) Save() error
type Model ¶
type Model struct {
ID PrimaryKey
}
type PrimaryKey ¶
type PrimaryKey uint
type Serialized ¶
type Serialized map[string]SerializedTable
type SerializedTable ¶
type SerializedTable struct {
Name string
Key PrimaryKey
Rows map[PrimaryKey]any
}
Click to show internal directories.
Click to hide internal directories.