db

package
v0.0.0-...-99214e8 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrModuleExists = errors.New("module has already been created")
View Source
var ErrModuleNotFound = errors.New("module does not found")

Functions

func New

func New() (*gorm.DB, error)

Types

type CreateModuleOptions

type CreateModuleOptions struct {
	ID   string
	Body *module.Body
}

type GetModuleOptions

type GetModuleOptions struct {
	EnabledOnly bool
}

type Module

type Module struct {
	ID        string       `db:"id"`
	Body      *module.Body `db:"body"`
	Enabled   bool         `db:"enabled"`
	CreatedAt time.Time    `db:"created_at"`
}

Module represents a single module.

func (*Module) IsEnabled

func (m *Module) IsEnabled() bool

type ModulesStore

type ModulesStore interface {
	List(ctx context.Context, opts GetModuleOptions) ([]*Module, error)
	Get(ctx context.Context, id string) (*Module, error)
	Create(ctx context.Context, opts CreateModuleOptions) error
	Update(ctx context.Context, id string, opts UpdateModuleOptions) error
	SetStatus(ctx context.Context, id string, enabled bool) error
	Delete(ctx context.Context, id string) error
}
var Modules ModulesStore

func NewModulesStore

func NewModulesStore(db *gorm.DB) ModulesStore

type UpdateModuleOptions

type UpdateModuleOptions struct {
	Body *module.Body
}

Jump to

Keyboard shortcuts

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