Documentation ¶
Index ¶
- Constants
- Variables
- type Repository
- type Store
- func (s *Store) Delete(postID int) error
- func (s *Store) Exists(field domain.PostField) bool
- func (s *Store) Find(postID int) (domain.PostFields, error)
- func (s *Store) FindByPostAndKey(postID int, key string) (domain.PostFields, error)
- func (s *Store) Insert(postID int, fields domain.PostFields) error
Constants ¶
const (
// The database table name for post fields.
TableName = "post_fields"
)
Variables ¶
var ( // ErrFieldExists is returned by validate when // a post field already exists. ErrFieldExists = errors.New("post field already exists") )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { Find(postID int) (domain.PostFields, error) FindByPostAndKey(postID int, key string) (domain.PostFields, error) Insert(postID int, fields domain.PostFields) error Delete(postID int) error Exists(field domain.PostField) bool }
Repository defines methods for post fields to interact with the database.
type Store ¶
Store defines the data layer for fields.
func (*Store) Delete ¶
Delete
Deletes all fields associated with a post. 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 field exists. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) Find ¶
func (s *Store) Find(postID int) (domain.PostFields, error)
Find
Returns a post field by searching with the given post ID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the category was not found by the given ID.
func (*Store) FindByPostAndKey ¶
FindByPostAndKey
Returns a post field by searching with the given post ID & key. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the post field was not found by the given ID.