repo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package repo is an implements app.UserRepo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, options ...Option) (*sql.DB, error)

Connect to database by options.

func InitMetrics

func InitMetrics(namespace string)

InitMetrics must be called once before using this package. It registers and initializes metrics used by this package.

Types

type Option

type Option func(*config)

Option for building flag.

func Host

func Host(host string) Option

Host sets the connection parameters.

func Name

func Name(name string) Option

Name sets the connection parameters.

func Pass

func Pass(pass string) Option

Pass sets the connection parameters.

func Port

func Port(port int) Option

Port sets the connection parameters.

func SSLMode

func SSLMode(sslMode string) Option

SSLMode sets the connection parameters.

func User

func User(user string) Option

User sets the connection parameters.

type Repo

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

Repo is an implements app.UserRepo. Responsible for working with database.

func New

func New(conn *sql.DB) *Repo

New creates and returns new app.UserRepo.

func (*Repo) Close

func (repo *Repo) Close() error

Close closes database connections.

func (*Repo) Code

func (repo *Repo) Code(ctx context.Context, id app.UserID) (code string, err error)

Code need for implements app.CodeRepo.

func (*Repo) CreateUser

func (repo *Repo) CreateUser(ctx context.Context, newUser app.User) (userID app.UserID, err error)

CreateUser need for implements app.UserRepo.

func (*Repo) DeleteSession

func (repo *Repo) DeleteSession(ctx context.Context, tokenID app.TokenID) error

DeleteSession need for implements app.SessionRepo.

func (*Repo) DeleteTaskNotification

func (repo *Repo) DeleteTaskNotification(ctx context.Context, id int) error

DeleteTaskNotification need for implements app.WAL.

func (*Repo) DeleteUser

func (repo *Repo) DeleteUser(ctx context.Context, userID app.UserID) error

DeleteUser need for implements app.UserRepo.

func (*Repo) ListUserByUsername

func (repo *Repo) ListUserByUsername(ctx context.Context, username string, page app.Page) (users []app.User, total int, err error)

ListUserByUsername need for implements app.UserRepo.

func (*Repo) NotificationTask

func (repo *Repo) NotificationTask(ctx context.Context) (task *app.TaskNotification, err error)

NotificationTask need for implements app.WAL.

func (*Repo) SaveCode

func (repo *Repo) SaveCode(ctx context.Context, userID app.UserID, code string) error

SaveCode need for implements app.CodeRepo.

func (*Repo) SaveSession

func (repo *Repo) SaveSession(ctx context.Context, userID app.UserID, tokenID app.TokenID, origin app.Origin) error

SaveSession need for implements app.SessionRepo.

func (*Repo) SessionByTokenID

func (repo *Repo) SessionByTokenID(ctx context.Context, tokenID app.TokenID) (session *app.Session, err error)

SessionByTokenID need for implements app.SessionRepo.

func (*Repo) UpdateEmail

func (repo *Repo) UpdateEmail(ctx context.Context, userID app.UserID, email string) error

UpdateEmail need for implements app.UserRepo.

func (*Repo) UpdatePassword

func (repo *Repo) UpdatePassword(ctx context.Context, userID app.UserID, passHash []byte) error

UpdatePassword need for implements app.UserRepo.

func (*Repo) UpdateUsername

func (repo *Repo) UpdateUsername(ctx context.Context, userID app.UserID, username string) error

UpdateUsername need for implements app.UserRepo.

func (*Repo) UserByEmail

func (repo *Repo) UserByEmail(ctx context.Context, email string) (user *app.User, err error)

UserByEmail need for implements app.UserRepo.

func (*Repo) UserByID

func (repo *Repo) UserByID(ctx context.Context, userID app.UserID) (user *app.User, err error)

UserByID need for implements app.UserRepo.

func (*Repo) UserByTokenID

func (repo *Repo) UserByTokenID(ctx context.Context, token app.TokenID) (user *app.User, err error)

UserByTokenID need for implements app.UserRepo.

func (*Repo) UserByUsername

func (repo *Repo) UserByUsername(ctx context.Context, username string) (user *app.User, err error)

UserByUsername need for implements app.UserRepo.

func (*Repo) UserID

func (repo *Repo) UserID(ctx context.Context, code string) (userID app.UserID, createAt time.Time, err error)

UserID need for implements app.CodeRepo.

Jump to

Keyboard shortcuts

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