datastore

package
v0.0.0-...-edeb3c3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Data

type Data interface {
	Key() string
}

type DataStore

type DataStore struct {
	models.Record
	ID   int64         `db:"pk,id"`
	Key  string        `db:"key"`
	Data types.JsonRaw `db:"data"`
}

func (DataStore) TableName

func (s DataStore) TableName() string

type DataStoreManager

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

func New

func New(db *db.DB, tablename, idfield string) (*DataStoreManager, error)

func (*DataStoreManager) Count

func (s *DataStoreManager) Count() (int, error)

func (*DataStoreManager) Delete

func (s *DataStoreManager) Delete(id int64) error

func (*DataStoreManager) DeleteAll

func (s *DataStoreManager) DeleteAll(key string) error

func (*DataStoreManager) DeleteOlderThan

func (s *DataStoreManager) DeleteOlderThan(unixtime int, key string) error

func (*DataStoreManager) Insert

func (s *DataStoreManager) Insert(data Data) (*DataStore, error)

func (*DataStoreManager) Select

func (s *DataStoreManager) Select(id int64) (*DataStore, error)

func (*DataStoreManager) SelectAll

func (s *DataStoreManager) SelectAll(key string) ([]DataStore, error)

func (*DataStoreManager) SelectLatest

func (s *DataStoreManager) SelectLatest(key string) (*DataStore, error)

TODO: all these functions prob cause heap allocs since we return a pointer

func (*DataStoreManager) Update

func (s *DataStoreManager) Update(id int64, data Data) error

Jump to

Keyboard shortcuts

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