Documentation ¶
Index ¶
- Variables
- type Info
- type Infos
- type NewOrUpdateMaybe
- type NewTag
- type RepositoryDb
- func (r RepositoryDb) Create(nm NewOrUpdateMaybe, userID string) (Info, error)
- func (r RepositoryDb) Delete(maybeID string) error
- func (r RepositoryDb) Query(userID string) (Infos, error)
- func (r RepositoryDb) QueryByID(maybeID string, userID string) (Info, error)
- func (r RepositoryDb) QueryByTag(tagID string, userID string) (Infos, error)
- func (r RepositoryDb) QueryTags(userID string) (Tags, error)
- func (r RepositoryDb) Update(um NewOrUpdateMaybe, maybeID string, userID string) error
- type Tag
- type Tags
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is used when a specific Product is requested but does not exist. ErrNotFound = errors.New("not found") // ErrInvalidID occurs when an ID is not in a valid form. ErrInvalidID = errors.New("ID is not in its proper form") // ErrInvalidTag occurs when a tag cannot be found in the dabase and cannot be created. ErrInvalidTag = errors.New("tag not found") // ErrForbidden occurs when a user tries to do something that is forbidden to them according to access control policies. ErrForbidden = errors.New("attempted action is not allowed") )
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { ID string `db:"maybe_id"` UserID string `db:"user_id"` Title string `db:"title"` Url string `db:"url"` Description string `db:"description"` Tags []Tag `db:"tags"` DateCreated string `db:"created_at"` DateUpdated string `db:"updated_at"` }
Info is the model for maybes.
type NewOrUpdateMaybe ¶
NewOrUpdateMaybe is the data for creating a new maybe or updating an existing maybe. Adding Tags is optional.
type NewTag ¶
type NewTag struct {
Name string `db:"name"`
}
NewTag is the data for creating a new tag.
type RepositoryDb ¶
RepositoryDb defines the repository for the maybe service.
func (RepositoryDb) Create ¶
func (r RepositoryDb) Create(nm NewOrUpdateMaybe, userID string) (Info, error)
Create adds a new maybe to the database with pre-filled ID and date fields.
func (RepositoryDb) Delete ¶
func (r RepositoryDb) Delete(maybeID string) error
Delete removes a maybe with given ID and its tags from the database.
func (RepositoryDb) Query ¶
func (r RepositoryDb) Query(userID string) (Infos, error)
Query retrieves all maybes from the database for the current user.
func (RepositoryDb) QueryByID ¶
func (r RepositoryDb) QueryByID(maybeID string, userID string) (Info, error)
QuerybyID retrieves a book by ID from the database.
func (RepositoryDb) QueryByTag ¶
func (r RepositoryDb) QueryByTag(tagID string, userID string) (Infos, error)
QueryByTag queries the database for all maybes of a certain tag for the current user.
func (RepositoryDb) QueryTags ¶
func (r RepositoryDb) QueryTags(userID string) (Tags, error)
QueryTags returns all (unique) tags for a given user.
func (RepositoryDb) Update ¶
func (r RepositoryDb) Update(um NewOrUpdateMaybe, maybeID string, userID string) error
Update updates an existing maybe.