Documentation ¶
Index ¶
- Variables
- type Info
- type NewSnippet
- type Store
- func (s Store) Create(ctx context.Context, n NewSnippet, now time.Time) (*Info, error)
- func (s Store) Delete(ctx context.Context, id string) error
- func (s Store) Latest(ctx context.Context) ([]Info, error)
- func (s Store) Retrieve(ctx context.Context, id string) (*Info, error)
- func (s Store) Update(ctx context.Context, id string, upd UpdateSnippet, now time.Time) error
- type UpdateSnippet
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is used when a specific Snippet is requested but does not exist. ErrNotFound = errors.New("Snippet not found") // ErrInvalidID occurs when an ID is not in a valid form. ErrInvalidID = errors.New("ID is not in its proper form") )
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { ID string `db:"snippet_id" json:"id"` Title string `db:"title" json:"title"` Content string `db:"content" json:"content"` DateExpires time.Time `db:"date_expires" json:"date_expires"` DateCreated time.Time `db:"date_created" json:"date_created"` DateUpdated time.Time `db:"date_updated" json:"date_updated"` }
Info represents a textual extract of something
type NewSnippet ¶
type NewSnippet struct { Title string `json:"title" validate:"required"` Content string `json:"content" validate:"required"` DateExpires time.Time `json:"date_expires" validate:"required"` }
NewSnippet contains information needed to create a new Snippet.
type Store ¶ added in v0.1.2
type Store struct {
// contains filtered or unexported fields
}
Store manages the set of API's for snippet access. It wraps a pgxpool.Pool connection pool.
type UpdateSnippet ¶
type UpdateSnippet struct { Title *string `json:"title"` Content *string `json:"content"` DateExpires *time.Time `json:"date_expires"` }
UpdateSnippet defines what information may be provided to modify an existing Snippet. 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.
Click to show internal directories.
Click to hide internal directories.