database

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound = errors.New("record not found")
	ErrInvalidRecord  = errors.New("invalid record format")
	ErrEmptyTable     = errors.New("table name cannot be empty")
)

Functions

func DeleteWhereTyped added in v0.0.8

func DeleteWhereTyped[T any](db *DB, table string, predicate func(T) bool) int

func InsertManyTyped added in v0.0.8

func InsertManyTyped[T any](db *DB, table string, records []T)

func MapTyped added in v0.0.8

func MapTyped[T any, R any](db *DB, table string, mapper func(T) R) []R

func SelectByIDTyped added in v0.0.8

func SelectByIDTyped[T any](db *DB, table string, id string) (*T, bool)

func SelectTyped added in v0.0.8

func SelectTyped[T any](db *DB, table string) []T

func SelectWhereTyped added in v0.0.8

func SelectWhereTyped[T any](db *DB, table string, predicate func(T) bool) []T

func UpdateWhereTyped added in v0.0.8

func UpdateWhereTyped[T any](db *DB, table string, predicate func(T) bool, updater func(T) T) int

func UpsertManyTyped added in v0.0.9

func UpsertManyTyped[T any](db *DB, table string, records []T)

func UpsertTyped added in v0.0.9

func UpsertTyped[T any](db *DB, table string, id string, record T)

func UpsertWhereTyped added in v0.0.9

func UpsertWhereTyped[T any](db *DB, table string, predicate func(T) bool, record T, updater func(T) T)

Types

type DB

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

func Connect

func Connect() *DB

func (*DB) Count added in v0.0.8

func (db *DB) Count(table string) int

func (*DB) Delete

func (db *DB) Delete(table string, id string) bool

func (*DB) DeleteWhere added in v0.0.8

func (db *DB) DeleteWhere(table string, predicate func(interface{}) bool) int

func (*DB) Exists added in v0.0.8

func (db *DB) Exists(table string, id string) bool

func (*DB) Insert

func (db *DB) Insert(table string, record interface{})

func (*DB) InsertMany added in v0.0.8

func (db *DB) InsertMany(table string, records []interface{})

func (*DB) Map added in v0.0.8

func (db *DB) Map(table string, mapper func(interface{}) interface{}) []interface{}

func (*DB) Select

func (db *DB) Select(table string) []interface{}

func (*DB) SelectByID added in v0.0.8

func (db *DB) SelectByID(table string, id string) (interface{}, bool)

func (*DB) SelectWhere added in v0.0.8

func (db *DB) SelectWhere(table string, predicate func(interface{}) bool) []interface{}

func (*DB) Transaction added in v0.0.8

func (db *DB) Transaction(fn func(*DB) error) error

func (*DB) Truncate added in v0.0.8

func (db *DB) Truncate(table string)

func (*DB) Update

func (db *DB) Update(table string, id string, record interface{}) bool

func (*DB) UpdateWhere added in v0.0.8

func (db *DB) UpdateWhere(table string, predicate func(interface{}) bool, updater func(interface{}) interface{}) int

func (*DB) Upsert added in v0.0.9

func (db *DB) Upsert(table string, id string, record interface{})

func (*DB) UpsertMany added in v0.0.9

func (db *DB) UpsertMany(table string, records []interface{})

func (*DB) UpsertWhere added in v0.0.9

func (db *DB) UpsertWhere(table string, predicate func(interface{}) bool, record interface{}, updater func(interface{}) interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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