Documentation
¶
Index ¶
- Constants
- Variables
- type ListConfig
- type Repository
- type Store
- func (s *Store) Create(p domain.PostCreate) (domain.PostDatum, error)
- func (s *Store) Delete(id int) error
- func (s *Store) Exists(id int) bool
- func (s *Store) ExistsBySlug(slug string) bool
- func (s *Store) Find(id int, layout bool) (domain.PostDatum, error)
- func (s *Store) FindBySlug(slug string) (domain.PostDatum, error)
- func (s *Store) List(meta params.Params, layout bool, cfg ListConfig) (domain.PostData, int, error)
- func (s *Store) Update(p domain.PostCreate) (domain.PostDatum, error)
Constants ¶
const (
// TableName is the database table name for posts.
TableName = "posts"
)
Variables ¶
var ( // ErrPostsExists is returned by validate when // a post already exists. ErrPostsExists = errors.New("post already exists") // ErrNoPageTemplate is returned by validate when // no page template has been matched with the // one passed. ErrNoPageTemplate = errors.New("no page template matched") // ErrNoPageLayout is returned by validate when // no page layout has been matched with the // one passed. ErrNoPageLayout = errors.New("no page layout matched") )
Functions ¶
This section is empty.
Types ¶
type ListConfig ¶
ListConfig defines the configuration for obtaining posts for Selects. Posts can be filtered by resource and status.
type Repository ¶
type Repository interface { List(meta params.Params, layout bool, cfg ListConfig) (domain.PostData, int, error) Find(id int, layout bool) (domain.PostDatum, error) FindBySlug(slug string) (domain.PostDatum, error) Create(p domain.PostCreate) (domain.PostDatum, error) Update(p domain.PostCreate) (domain.PostDatum, error) Delete(id int) error Exists(id int) bool ExistsBySlug(slug string) bool }
Repository defines methods for posts to interact with the database.
type Store ¶
Store defines the data layer for posts.
func (*Store) Create ¶
Create
Returns a new post upon creation. Returns errors.CONFLICT if the the category (name) 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
Returns nil if the category was successfully deleted. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if the category was not found.
func (*Store) Exists ¶
Exists
Returns a bool indicating if the post exists by ID. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) ExistsBySlug ¶
ExistsBySlug
Returns a bool indicating if the post exists by slug. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) Find ¶
Find
Returns a post by searching with the given ID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the post was not found by the given ID.
func (*Store) FindBySlug ¶
FindBySlug
Returns a post by searching with the given slug. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the post was not found by the given slug.