repository

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateRecord error = errors.New("duplicate record")
	ErrRecordNotFound  error = errors.New("record not found")
)

Functions

This section is empty.

Types

type EmailVerification

type EmailVerification struct {
	Code      string
	UserID    string
	CreatedAt time.Time
	ExpiresAt time.Time
}

type Postgres

type Postgres struct{ *sqlx.DB }

Postgres represents a user repository instance with the given database connection

func NewPostgres

func NewPostgres(dbConn *sqlx.DB) *Postgres

New creates a new user repository instance

func (*Postgres) DeleteByID

func (p *Postgres) DeleteByID(ctx context.Context, id string) error

func (*Postgres) Insert

func (p *Postgres) Insert(ctx context.Context, u *User) (*User, error)

func (*Postgres) InsertEmailVerification

func (p *Postgres) InsertEmailVerification(ctx context.Context, in EmailVerification) error

func (*Postgres) SelectByEmail

func (p *Postgres) SelectByEmail(ctx context.Context, email string) (*User, error)

func (*Postgres) SelectByID

func (p *Postgres) SelectByID(ctx context.Context, id string) (*User, error)

SelectByID selects a user by id and returns the user

type User

type User struct {
	ID            string
	Fullname      string
	Username      string
	Birthdate     string
	Email         string
	PasswordHash  string
	Role          string
	EmailVerified bool
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

User represents a user in the database table

Jump to

Keyboard shortcuts

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