Documentation ¶
Index ¶
- func ConnString(host string, port int, user, password, dbName string) string
- type Db
- func (d *Db) AttachUserRole(u *models.User, r *models.Role) error
- func (d *Db) Auth(user *models.User, password string) error
- func (d *Db) CheckUserRole(userid, roleid uuid.UUID) error
- func (d *Db) CreateGroup(g *models.Group) error
- func (d *Db) CreateImage(i *models.Image, data []byte) error
- func (d *Db) CreateProfile(p *models.Profile) error
- func (d *Db) CreateRole(r *models.Role) error
- func (d *Db) CreateUser(u *models.User) error
- func (d *Db) GetAllImages() ([]models.Image, error)
- func (d *Db) GetGroupByID(id uuid.UUID) (*models.Group, error)
- func (d *Db) GetGroupByName(name string) (*models.Group, error)
- func (d *Db) GetGroupByQuery(query string, arg ...interface{}) ([]models.Group, error)
- func (d *Db) GetGroupMembers(gid uuid.UUID) ([]models.User, error)
- func (d *Db) GetGroupsByOwnerID(ownerid uuid.UUID) ([]models.Group, error)
- func (d *Db) GetImageByID(id uuid.UUID) (*models.Image, error)
- func (d *Db) GetImageByQuery(query string, arg ...interface{}) ([]models.Image, error)
- func (d *Db) GetImageBySha256(sum string) (*models.Image, error)
- func (d *Db) GetImagesByOwnerID(ownerid uuid.UUID) ([]models.Image, error)
- func (d *Db) GetProfileByID(id uuid.UUID) (*models.Profile, error)
- func (d *Db) GetProfileByQuery(query string, args ...interface{}) ([]models.Profile, error)
- func (d *Db) GetProfileByUserID(userid uuid.UUID) (*models.Profile, error)
- func (d *Db) GetRoleByID(id uuid.UUID) (*models.Role, error)
- func (d *Db) GetRoleByName(name string) (*models.Role, error)
- func (d *Db) GetRoleByQuery(query string, arg ...interface{}) ([]models.Role, error)
- func (d *Db) GetSharedImagesByUserID(userid uuid.UUID) ([]models.Image, error)
- func (d *Db) GetUserByEmail(email string) (*models.User, error)
- func (d *Db) GetUserByID(id uuid.UUID) (*models.User, error)
- func (d *Db) GetUserByQuery(query string, args ...interface{}) ([]models.User, error)
- func (d *Db) GetUserByUsername(username string) (*models.User, error)
- func (d *Db) GetUserRoles(userid uuid.UUID) ([]models.Role, error)
- func (d *Db) GetUsersByID(ids ...uuid.UUID) ([]models.User, error)
- func (d *Db) ShareImage(imageshare *models.ImageShare) error
- func (d *Db) UpdateUserToken(uid uuid.UUID, newtoken string) (*models.User, error)
- func (d *Db) VerifyToken(id, token uuid.UUID) bool
- type InvalidError
- type ModelFound
- type ModelNotFound
- type UnknownError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Db ¶
Db wraps a database with helper functions
func (*Db) AttachUserRole ¶
AttachUserRole creates a relation between a user and a given role
func (*Db) CheckUserRole ¶
CheckUserRole checks to see if a user has a given role
func (*Db) CreateGroup ¶
CreateGroup inserts a group into the database
func (*Db) CreateImage ¶
CreateImage generates missing data and inserts an entry in the database
func (*Db) CreateProfile ¶
CreateProfile Inserts a profile into the database
func (*Db) CreateRole ¶
CreateRole sets the remaining fields and create's a new Role
func (*Db) CreateUser ¶
CreateUser a new user in the given database
func (*Db) GetAllImages ¶
GetAllImages returns every image
func (*Db) GetGroupByID ¶
GetGroupByID is used by the database resolver to find groups
func (*Db) GetGroupByName ¶
GetGroupByName retrieves a group by it's name
func (*Db) GetGroupByQuery ¶
GetGroupByQuery runs the query and returns a group and error
func (*Db) GetGroupMembers ¶
GetGroupMembers retrives a list of users belonging to a group
func (*Db) GetGroupsByOwnerID ¶
GetGroupsByOwnerID retrives a list of groups by the owner_id
func (*Db) GetImageByID ¶
GetImageByID retrieves an image by it's ID
func (*Db) GetImageByQuery ¶
GetImageByQuery retrieves models using a query
func (*Db) GetImageBySha256 ¶
GetImageBySha256 retrieves an image based on it's sha256 sum
func (*Db) GetImagesByOwnerID ¶
GetImagesByOwnerID retrives a list of images based on the given owner_id
func (*Db) GetProfileByID ¶
GetProfileByID retrieves a profile via it's ID
func (*Db) GetProfileByQuery ¶
GetProfileByQuery returns a list of profiles matching the query and given arguments.
func (*Db) GetProfileByUserID ¶
GetProfileByUserID retrieves a profile via it's User ID association
func (*Db) GetRoleByID ¶
GetRoleByID retrieves a role with it's user ID's
func (*Db) GetRoleByName ¶
GetRoleByName finds a role using it's name
func (*Db) GetRoleByQuery ¶
GetRoleByQuery runs a query to get models
func (*Db) GetSharedImagesByUserID ¶
GetSharedImagesByUserID returns the list of images by the UserID
func (*Db) GetUserByEmail ¶
GetUserByEmail returns a user model via the email address
func (*Db) GetUserByID ¶
GetUserByID is used by the database resolver to find users
func (*Db) GetUserByQuery ¶
GetUserByQuery runs the given query with the given argument and returns a user model
func (*Db) GetUserByUsername ¶
GetUserByUsername returns a user model containing the username
func (*Db) GetUserRoles ¶
GetUserRoles returns a list of roles held by a user ID
func (*Db) GetUsersByID ¶
GetUsersByID returns a slice of user models from the list of given ids
func (*Db) ShareImage ¶
func (d *Db) ShareImage(imageshare *models.ImageShare) error
ShareImage inserts an image share
func (*Db) UpdateUserToken ¶
UpdateUserToken updates a users token TODO: Factor using a standard Update method
type InvalidError ¶
type InvalidError struct {
// contains filtered or unexported fields
}
InvalidError error type
func NewInvalidError ¶
func NewInvalidError(err error) *InvalidError
NewInvalidError generates a meaningful error message when a model isn't found.
func (*InvalidError) Error ¶
func (m *InvalidError) Error() string
Error fullfills the interface for errors
type ModelFound ¶
type ModelFound struct {
// contains filtered or unexported fields
}
ModelFound error type
func NewModelFound ¶
func NewModelFound(err error) *ModelFound
NewModelFound generates a meaningful error message when a model is found.
func (*ModelFound) Error ¶
func (m *ModelFound) Error() string
Error fullfills the interface for errors
type ModelNotFound ¶
type ModelNotFound struct {
// contains filtered or unexported fields
}
ModelNotFound error type
func NewModelNotFound ¶
func NewModelNotFound(err error) *ModelNotFound
NewModelNotFound generates a meaningful error message when a model isn't found.
func (*ModelNotFound) Error ¶
func (m *ModelNotFound) Error() string
Error fullfills the interface for errors
type UnknownError ¶
type UnknownError struct {
// contains filtered or unexported fields
}
UnknownError is to log unknown errors
func NewUnknownError ¶
func NewUnknownError(err error) *UnknownError
NewUnknownError generates a meaningful error message when an unknown error occurs
func (*UnknownError) Error ¶
func (u *UnknownError) Error() string
Error fullfills the interface for errors