backend

package
v0.0.0-...-35d8e6d Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackendJSON   = "json"
	BackendSqlite = "sqlite3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Will be called to initialize the instance
	Init(cfg *config.Config) error

	CreateItem(i *models.Item) (*models.Item, error)
	ListAllItems() ([]*models.Item, error)
	GetItemByID(id int) (*models.Item, error)
	UpdateItemByID(id int, i *models.Item) (*models.Item, error)
	RemoveItemByID(id int) (*models.Item, error)

	PublicKeys() ([]string, error)
	AddPublicKeys(pubKeys ...string) error
	RemovePublicKeys(pubKeys ...string) error

	Flush() error
}

func Get

func Get() (Backend, error)

type JSONBackend

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

func (*JSONBackend) AddPublicKeys

func (*JSONBackend) AddPublicKeys(pubKeys ...string) error

AddPublicKeys implements Backend

func (*JSONBackend) CreateItem

func (jb *JSONBackend) CreateItem(i *models.Item) (*models.Item, error)

CreateItem implements Backend

func (*JSONBackend) Flush

func (jb *JSONBackend) Flush() error

Flush implements Backend

func (*JSONBackend) GetItemByID

func (jb *JSONBackend) GetItemByID(id int) (*models.Item, error)

GetItemByID implements Backend

func (*JSONBackend) Init

func (jb *JSONBackend) Init(cfg *config.Config) error

Init implements Backend

func (*JSONBackend) ListAllItems

func (jb *JSONBackend) ListAllItems() ([]*models.Item, error)

ListAllItems implements Backend

func (*JSONBackend) PublicKeys

func (jb *JSONBackend) PublicKeys() ([]string, error)

PublicKeys implements Backend

func (*JSONBackend) RemoveItemByID

func (jb *JSONBackend) RemoveItemByID(id int) (*models.Item, error)

RemoveItemByID implements Backend

func (*JSONBackend) RemovePublicKeys

func (*JSONBackend) RemovePublicKeys(pubKeys ...string) error

RemovePublicKeys implements Backend

func (*JSONBackend) UpdateItemByID

func (jb *JSONBackend) UpdateItemByID(id int, i *models.Item) (*models.Item, error)

UpdateItemByID implements Backend

type PublicKey

type PublicKey struct {
	ID        int64 `xorm:"pk autoincr 'id'"`
	Key       string
	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
}

type SqliteBackend

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

func (*SqliteBackend) AddPublicKeys

func (b *SqliteBackend) AddPublicKeys(pubKeys ...string) error

AddPublicKeys implements Backend

func (*SqliteBackend) CreateItem

func (b *SqliteBackend) CreateItem(i *models.Item) (*models.Item, error)

CreateItem implements Backend

func (*SqliteBackend) Flush

func (b *SqliteBackend) Flush() error

Flush implements Backend

func (*SqliteBackend) GetItemByID

func (b *SqliteBackend) GetItemByID(id int) (*models.Item, error)

GetItemByID implements Backend

func (*SqliteBackend) Init

func (b *SqliteBackend) Init(cfg *config.Config) error

Init implements Backend

func (*SqliteBackend) ListAllItems

func (b *SqliteBackend) ListAllItems() ([]*models.Item, error)

ListAllItems implements Backend

func (*SqliteBackend) PublicKeys

func (b *SqliteBackend) PublicKeys() ([]string, error)

PublicKeys implements Backend

func (*SqliteBackend) RemoveItemByID

func (*SqliteBackend) RemoveItemByID(id int) (*models.Item, error)

RemoveItemByID implements Backend

func (*SqliteBackend) RemovePublicKeys

func (*SqliteBackend) RemovePublicKeys(pubKeys ...string) error

RemovePublicKeys implements Backend

func (*SqliteBackend) UpdateItemByID

func (*SqliteBackend) UpdateItemByID(id int, i *models.Item) (*models.Item, error)

UpdateItemByID implements Backend

Jump to

Keyboard shortcuts

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