forms

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: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The database table name for forms.
	TableName = "forms"
	// The database table name for form fields.
	FieldsTableName = "form_fields"
)

Variables

View Source
var (
	// ErrFormExists is returned by validate when
	// a form already exists.
	ErrFormExists = errors.New("form already exists")
)

Functions

This section is empty.

Types

type Repository

type Repository interface {
	List(meta params.Params) (domain.Forms, int, error)
	Find(id int) (domain.Form, error)
	FindByUUID(uniq uuid.UUID) (domain.Form, error)
	Create(f domain.Form) (domain.Form, error)
	Update(f domain.Form) (domain.Form, error)
	Delete(id int) error
	Submit(f domain.FormSubmission) error
}

Repository defines methods for forms to interact with the database.

type Store

type Store struct {
	*config.Config
	// contains filtered or unexported fields
}

Store defines the data layer for forms.

func New

func New(cfg *config.Config) *Store

New

Creates a new form store.

func (*Store) Create

func (s *Store) Create(f domain.Form) (domain.Form, error)

Create

Returns a new form upon creation. Returns errors.CONFLICT if the the form (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

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

Delete

Returns nil if the fork was successfully deleted. Returns errors.NOTFOUND if the form was not found. Returns errors.INTERNAL if the SQL query was invalid.

func (*Store) Find

func (s *Store) Find(id int) (domain.Form, error)

Find

Returns a form by searching with the given ID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the form was not found by the given ID.

func (*Store) FindByUUID

func (s *Store) FindByUUID(uniq uuid.UUID) (domain.Form, error)

FindByUUID

Returns a form by searching with the given UUID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the form was not found by the given slug.

func (*Store) List

func (s *Store) List(meta params.Params) (domain.Forms, int, error)

List

Returns a slice of forms with the total amount. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if there are no forms available.

func (*Store) Submit

func (s *Store) Submit(f domain.FormSubmission) error

Submit

Returns nil if the submissions was stored successfully.

func (*Store) Update

func (s *Store) Update(f domain.Form) (domain.Form, error)

Update

Returns an updated form. Returns errors.CONFLICT if the validation failed. Returns errors.INTERNAL if the SQL query was invalid or the function could not obtain the newly created ID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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