Documentation ¶
Overview ¶
Package card implements all business logic regarding cards and related types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is used when a specific Card is requested but does not exist. ErrNotFound = errors.New("card not found") // ErrInvalidID is used when an invalid UUID is provided. ErrInvalidID = errors.New("ID is not in its proper form") // ErrForbidden occurs when a user tries to do something that is forbidden to // them according to our access control policies. ErrForbidden = errors.New("Attempted action is not allowed") )
Predefined errors identify expected failure conditions.
Functions ¶
Types ¶
type Card ¶
type Card struct { ID string `db:"card_id" json:"id"` Name string `db:"name" json:"name"` Content string `db:"content" json:"content"` UserID string `db:"user_id" json:"userID"` DateCreated time.Time `db:"date_created" json:"dateCreated"` DateUpdated time.Time `db:"date_updated" json:"dateUpdated"` }
Card is an datastructure for a Card object.
func Create ¶
func Create(ctx context.Context, db *sqlx.DB, user auth.Claims, nc NewCard, now time.Time) (*Card, error)
Create adds a Card to the database. It returns the created Card with fields like ID and DateCreated populated..
type NewCard ¶
type NewCard struct { Name string `json:"name" validate:"required"` Content string `json:"content"` }
NewCard is what we require from admin when adding a Card.
type UpdateCard ¶
UpdateCard defines what information may be provided to modify an existing Card. All fields are optional so clients can send just the fields they want changed. It uses pointer fields so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types but we make exceptions around marshalling/unmarshalling.