database

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

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserNotFound = errors.New("user not found")

Functions

This section is empty.

Types

type AuthSession

type AuthSession struct {
	ID        uuid.UUID
	UserID    uuid.UUID
	CreatedAt time.Time
	ExpiresAt time.Time
}

type AuthUser

type AuthUser struct {
	ID        uuid.UUID
	Document  string
	Name      string
	Email     string
	Password  string
	Birthdate time.Time
	Type      AuthUserType
}

type AuthUserType

type AuthUserType string
const (
	AuthUserTypeDefault AuthUserType = "default"
	AuthUserTypeAdmin   AuthUserType = "admin"
)

func (*AuthUserType) Scan

func (e *AuthUserType) Scan(src interface{}) error

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type InsertSessionParams

type InsertSessionParams struct {
	ID        uuid.UUID
	UserID    uuid.UUID
	CreatedAt time.Time
	ExpiresAt time.Time
}

type InsertUserParams

type InsertUserParams struct {
	ID        uuid.UUID
	Document  string
	Name      string
	Email     string
	Password  string
	Birthdate time.Time
	Type      AuthUserType
}

type NullAuthUserType

type NullAuthUserType struct {
	AuthUserType AuthUserType
	Valid        bool // Valid is true if AuthUserType is not NULL
}

func (*NullAuthUserType) Scan

func (ns *NullAuthUserType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAuthUserType) Value

func (ns NullAuthUserType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) GetUserByDocument

func (q *Queries) GetUserByDocument(ctx context.Context, document string) (AuthUser, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (AuthUser, error)

func (*Queries) InsertSession

func (q *Queries) InsertSession(ctx context.Context, arg InsertSessionParams) error

func (*Queries) InsertUser

func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SessionRepository

type SessionRepository struct {
	// contains filtered or unexported fields
}

func NewSessionRepository

func NewSessionRepository(dbPool *pgxpool.Pool) *SessionRepository

func (*SessionRepository) Save

func (s *SessionRepository) Save(ctx context.Context, session *entity.Session) error

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository(dbPool *pgxpool.Pool) *UserRepository

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, user *entity.User) error

func (*UserRepository) GetUserByDocument

func (r *UserRepository) GetUserByDocument(ctx context.Context, document string) (*entity.User, error)

func (*UserRepository) GetUserByEmail

func (r *UserRepository) GetUserByEmail(ctx context.Context, email string) (*entity.User, error)

Jump to

Keyboard shortcuts

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