Documentation ¶
Index ¶
- Constants
- Variables
- type Repository
- type Store
- func (s *Store) Create(r domain.Redirect) (domain.Redirect, error)
- func (s *Store) Delete(id int) error
- func (s *Store) Exists(id int) bool
- func (s *Store) ExistsByFrom(from string) bool
- func (s *Store) Find(id int) (domain.Redirect, error)
- func (s *Store) FindByFrom(from string) (domain.Redirect, error)
- func (s *Store) List(meta params.Params) (domain.Redirects, int, error)
- func (s *Store) Update(r domain.Redirect) (domain.Redirect, error)
Constants ¶
const (
// The database table name for redirects.
TableName = "redirects"
)
Variables ¶
var ( // ErrRedirectExists is returned by validate when // a redirect from path already exists. ErrRedirectExists = errors.New("redirect already exists") )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { List(meta params.Params) (domain.Redirects, int, error) Find(id int) (domain.Redirect, error) FindByFrom(from string) (domain.Redirect, error) Create(redirect domain.Redirect) (domain.Redirect, error) Update(redirect domain.Redirect) (domain.Redirect, error) Delete(id int) error Exists(id int) bool ExistsByFrom(from string) bool }
Repository defines methods for redirects to interact with the database.
type Store ¶
Store defines the data layer for redirects.
func (*Store) Create ¶
Create
Returns a new redirect upon creation. Returns errors.CONFLICT if the the redirect (from_path) already exists. Returns errors.INTERNAL if the SQL query was invalid or the function could not get the newly created ID.
func (*Store) Delete ¶
Delete
Deletes a redirect. Returns nil if the redirect was successfully deleted. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if the redirect was not found.
func (*Store) Exists ¶
Exists
Returns a bool indicating if the redirect exists by ID. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) ExistsByFrom ¶
ExistsByFrom
Returns a bool indicating if the redirect exists by from path. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) Find ¶
Find
Returns a redirect by searching with the given ID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the redirect was not found by the given ID.
func (*Store) FindByFrom ¶
Find
Returns a redirect by searching with the given from path. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the redirect was not found by the given ID.