data

package
v0.0.0-...-4eeec6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 NewRepo

func NewRepo(db *sqlx.DB) Repo

NewRepo constructs a Repo

func (*Repo) CheckExistsPublisherWithName

func (r *Repo) CheckExistsPublisherWithName(ctx context.Context, name string) (bool, error)

CheckExistsPublisherWithName returns true if publisher with such name already exists otherwise returns false

func (*Repo) CreateUser

func (r *Repo) CreateUser(ctx context.Context, user User) error

CreateUser inserts a new user into the database

func (*Repo) GetRoleByID

func (r *Repo) GetRoleByID(ctx context.Context, roleID uuid.UUID) (role Role, err error)

GetRoleByID returns role by id

func (*Repo) GetRoleByName

func (r *Repo) GetRoleByName(ctx context.Context, roleName string) (role Role, err error)

GetRoleByName returns role by name

func (*Repo) GetUserByID

func (r *Repo) GetUserByID(ctx context.Context, userID string) (user User, err error)

GetUserByID returns user by id

func (*Repo) GetUserByUsername

func (r *Repo) GetUserByUsername(ctx context.Context, username string) (user User, err error)

GetUserByUsername returns user by username

func (*Repo) UpdateUser

func (r *Repo) UpdateUser(ctx context.Context, user User) error

UpdateUser updates user

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL