store

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseJsonStore

type BaseJsonStore[T BaseModel[T]] struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore[T BaseModel[T]](jsonFile string) *BaseJsonStore[T]

func (*BaseJsonStore[T]) Add

func (s *BaseJsonStore[T]) Add(record T) bool

add if not exist, or force replace it

func (*BaseJsonStore[T]) ById

func (s *BaseJsonStore[T]) ById(id string) T

func (*BaseJsonStore[T]) Data

func (s *BaseJsonStore[T]) Data() []T

func (*BaseJsonStore[T]) Init

func (s *BaseJsonStore[T]) Init() error

load from json file, tmp use

func (*BaseJsonStore[T]) Refresh

func (s *BaseJsonStore[T]) Refresh() error

func (*BaseJsonStore[T]) Save

func (s *BaseJsonStore[T]) Save() error

save to json file, tmp use

func (*BaseJsonStore[T]) Update

func (s *BaseJsonStore[T]) Update(record T) bool

add if not exist, or update it, not force

type BaseModel

type BaseModel[T interface{}] interface {
	GetID() string
	Assign(record T)
	AssignForce(record T)
}

Jump to

Keyboard shortcuts

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