fields

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The database table name for post fields.
	TableName = "post_fields"
)

Variables

View Source
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

type Store struct {
	*config.Config
}

Store defines the data layer for fields.

func New

func New(cfg *config.Config) *Store

New

Creates a new post fields store.

func (*Store) Delete

func (s *Store) Delete(postID int) error

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

func (s *Store) Exists(field domain.PostField) bool

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

func (s *Store) FindByPostAndKey(postID int, key string) (domain.PostFields, error)

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.

func (*Store) Insert

func (s *Store) Insert(postID int, fields domain.PostFields) error

Insert

Insert checks to see if the record should be deleted before updating or creating the new record depending on if the field exists in the store.

Jump to

Keyboard shortcuts

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