Documentation ¶
Index ¶
- Constants
- Variables
- type Repo
- func (r *Repo) CheckExistsPublisherWithName(ctx context.Context, name string) (bool, error)
- func (r *Repo) CreateUser(ctx context.Context, user User) error
- func (r *Repo) GetRoleByID(ctx context.Context, roleID uuid.UUID) (role Role, err error)
- func (r *Repo) GetRoleByName(ctx context.Context, roleName string) (role Role, err error)
- func (r *Repo) GetUserByID(ctx context.Context, userID string) (user User, err error)
- func (r *Repo) GetUserByUsername(ctx context.Context, username string) (user User, err error)
- func (r *Repo) UpdateUser(ctx context.Context, user User) error
- type Role
- type User
Constants ¶
View Source
const ( DefaultRoleName string = "user" PublisherRoleName string = "publisher" )
User role names
Variables ¶
View Source
var ( // ErrNotFound is used when requested entity is not found ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo manages API for user access
func (*Repo) CheckExistsPublisherWithName ¶
CheckExistsPublisherWithName returns true if publisher with such name already exists otherwise returns false
func (*Repo) CreateUser ¶
CreateUser inserts a new user into the database
func (*Repo) GetRoleByID ¶
GetRoleByID returns role by id
func (*Repo) GetRoleByName ¶
GetRoleByName returns role by name
func (*Repo) GetUserByID ¶
GetUserByID returns user by id
func (*Repo) GetUserByUsername ¶
GetUserByUsername returns user by username
type Role ¶
type Role struct { ID uuid.UUID `db:"id"` Name string `db:"name"` Description string `db:"description"` DateCreated time.Time `db:"date_created"` DateUpdated sql.NullTime `db:"date_updated"` }
Role represents a user role
type User ¶
type User struct { ID uuid.UUID `db:"id"` Username string `db:"username"` Name string `db:"name"` PasswordHash []byte `db:"password_hash"` RoleID uuid.UUID `db:"role_id"` AvatarURL sql.NullString `db:"avatar_url"` DateCreated time.Time `db:"date_created"` DateUpdated sql.NullTime `db:"date_updated"` }
User represents a user
Click to show internal directories.
Click to hide internal directories.