repo

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package repo provides a wrapper around database.

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Repo

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

func New

func New(db *sql.DB) *Repo

func (*Repo) Close

func (repo *Repo) Close() error

func (*Repo) CreateUser

func (repo *Repo) CreateUser(ctx context.Context, user *UserCore) (string, error)

func (*Repo) DeleteUserById

func (repo *Repo) DeleteUserById(ctx context.Context, id string) error

func (*Repo) GetUserByEmail

func (repo *Repo) GetUserByEmail(ctx context.Context, email string) (*User, error)

func (*Repo) GetUserById

func (repo *Repo) GetUserById(ctx context.Context, userId string) (*User, error)

func (*Repo) Migrate

func (repo *Repo) Migrate() error

func (*Repo) Update

func (repo *Repo) Update(ctx context.Context, id string, updates map[string]any) error

type Stmts

type Stmts struct {
	CreateUserTable *sql.Stmt
	GetUserById     *sql.Stmt
	GetUserByEmail  *sql.Stmt
	CreateUser      *sql.Stmt
	DeleteUserById  *sql.Stmt
	Update          *sql.Stmt
}

func (*Stmts) Close

func (s *Stmts) Close() error

type User

type User struct {
	UserCore
	Role          string `json:"role"`
	FullName      string `json:"full_name,omitempty"`
	Username      string `json:"username,omitempty"`
	DateOfBirth   string `json:"date_of_birth"`
	Gender        string `json:"gender,omitempty"`
	PhoneNumber   string `json:"phone_number,omitempty"`
	AccountStatus string `json:"account_status"`
	ImageUrl      string `json:"image_url"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
	Id            string `json:"id"`
}

type UserCore

type UserCore struct {
	Email        string `json:"email"`
	PasswordHash string `json:"-"`
}

Jump to

Keyboard shortcuts

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