model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicSync     string = "sync"
	StatusCreated string = "created"
	StatusUpdated string = "updated"
	StatusDeleted string = "deleted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Insert(id int, resource interface{}, layer func(id int, resource interface{}))
	Erase(id int, layer func(id int, resource interface{}))
	Get(id int) (resource interface{}, ok bool)
	GetAll() (resources []interface{})
	Clear()
}

func NewCache

func NewCache() Cache

type Id

type Id interface {
	GetId() int
	SetId(id int)
}

type Model

type Model interface {
	Table() database.Table

	GetList() ([]interface{}, error)
	Get(id int) (interface{}, error)
	Create(resource Id, context interface{}) (int, error)
	Update(resource Id, context interface{}) error
	Delete(id int, context interface{}) error
	Sync() error
	SyncSingle(id int) (interface{}, error)
	SetBeforeInsertLayer(layer func(id int, resource interface{}))
	SetBeforeEraseLayer(layer func(id int, resource interface{}))
	SetBeforeNotifyLayer(layer func(id int, e *event.Event))
}

func New

func New(db database.Database, resource Id, topic string, isCache bool, tableName string) (Model, error)

type PrimaryKey

type PrimaryKey struct {
	database.PrimaryKey
}

func (*PrimaryKey) GetId

func (p *PrimaryKey) GetId() int

func (*PrimaryKey) SetId

func (p *PrimaryKey) SetId(id int)

type Resource

type Resource struct {
	database.Resource
}

func (*Resource) GetId

func (r *Resource) GetId() int

func (*Resource) SetId

func (r *Resource) SetId(id int)

Jump to

Keyboard shortcuts

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