Documentation ¶
Index ¶
- Constants
- type Repository
- type Store
- func (s *Store) Create(name string, value interface{}) error
- func (s *Store) Exists(name string) bool
- func (s *Store) Find(name string) (interface{}, error)
- func (s *Store) GetTheme() (string, error)
- func (s *Store) Insert(options domain.OptionsDBMap) error
- func (s *Store) Map() (domain.OptionsDBMap, error)
- func (s *Store) SetTheme(theme string) error
- func (s *Store) Struct() domain.Options
- func (s *Store) Update(name string, value interface{}) error
Constants ¶
const (
// The database table name for options.
TableName = "options"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { Map() (domain.OptionsDBMap, error) Struct() domain.Options Find(name string) (interface{}, error) Insert(options domain.OptionsDBMap) error Create(name string, value interface{}) error Update(name string, value interface{}) error GetTheme() (string, error) SetTheme(theme string) error Exists(name string) bool }
Repository defines methods for options to interact with the database.
type Store ¶
Store defines the data layer for options.
func (*Store) Create ¶
Create
Returns a nil upon creation. Returns errors.INTERNAL if the SQL query was invalid or the function could not get the newly created ID.
func (*Store) Exists ¶
Exists
Returns a bool indicating if the option exists by name. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) Find ¶
Find
Returns a option by searching with the given name. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the option was not found by the given name.
func (*Store) GetTheme ¶
GetTheme
Returns the currently active theme within the options table if it has been retrieved successfully. Returns errors.NOTFOUND if the 'active_theme' column could not be found. Returns errors.INVALID if the option value could not be successfully parsed to a string.
func (*Store) Insert ¶
func (s *Store) Insert(options domain.OptionsDBMap) error
Insert
Updates or creates a new option depending on if it already exists in the database.
func (*Store) Map ¶
func (s *Store) Map() (domain.OptionsDBMap, error)
Map
Returns options as a map. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if there are no options available.