database

package
v0.0.0-...-44a2381 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoRows

func IsNoRows(err error) bool

func IsUniqueViolation

func IsUniqueViolation(err error) bool

Types

type DB

type DB struct {
	*sqlx.DB
	Builder squirrel.StatementBuilderType
	Logger  *slog.Logger
}

func New

func New(logger *slog.Logger, dsn string, automigrate bool) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

type FindOptions

type FindOptions struct {
	Limit  uint64
	Offset uint64
}

type FindUserFilter

type FindUserFilter struct {
	Name           *string
	Surname        *string
	Patronymic     *string
	PassportSerie  *int
	PassportNumber *int
	Address        *string
}

type InsertSessionDTO

type InsertSessionDTO struct {
	User  model.ID
	Task  model.ID
	Begin time.Time
}

func NewInsertSessionDTO

func NewInsertSessionDTO(user model.ID, task model.ID) InsertSessionDTO

type InsertUserDTO

type InsertUserDTO struct {
	Name           string
	Surname        string
	Patronymic     *string
	PassportSerie  int
	PassportNumber int
	Address        string
}

func NewInsertUserDTO

func NewInsertUserDTO(
	name string, surname string,
	passportSerie int, passportNumber int,
	address string,
) InsertUserDTO

func NewInsertUserDTOWithPatronymic

func NewInsertUserDTOWithPatronymic(
	name string, surname string, patronymic string,
	passportSerie int, passportNumber int,
	address string,
) InsertUserDTO

func (*InsertUserDTO) SetPatronymic

func (dto *InsertUserDTO) SetPatronymic(patronymic string)

type SessionDAO

type SessionDAO struct {
	Logger *slog.Logger
	*DB
}

func NewSessionDAO

func NewSessionDAO(logger *slog.Logger, db *DB) *SessionDAO

func (*SessionDAO) FindByUser

func (dao *SessionDAO) FindByUser(ctx context.Context, user model.ID, opts SessionTimelineOptions) ([]model.Session, error)

func (*SessionDAO) Get

func (dao *SessionDAO) Get(ctx context.Context, id model.ID) (model.Session, error)

func (*SessionDAO) Insert

func (dao *SessionDAO) Insert(ctx context.Context, dto InsertSessionDTO) (model.ID, error)

func (*SessionDAO) LastByTaskAndUser

func (dao *SessionDAO) LastByTaskAndUser(ctx context.Context, task, user model.ID) (model.Session, error)

func (*SessionDAO) Update

func (dao *SessionDAO) Update(ctx context.Context, id model.ID, dto UpdateSessionDTO) error

type SessionTimelineOptions

type SessionTimelineOptions struct {
	After  *time.Time
	Before *time.Time
}

type UpdateSessionDTO

type UpdateSessionDTO struct {
	End time.Time
}

type UpdateUserDTO

type UpdateUserDTO struct {
	Name           *string
	Surname        *string
	Patronymic     *string
	PassportSerie  *int
	PassportNumber *int
	Address        *string
}

type UserDAO

type UserDAO struct {
	Logger *slog.Logger
	*DB
}

func NewUserDAO

func NewUserDAO(logger *slog.Logger, db *DB) *UserDAO

func (*UserDAO) Delete

func (dao *UserDAO) Delete(ctx context.Context, id model.ID) error

func (*UserDAO) Find

func (dao *UserDAO) Find(ctx context.Context, filter FindUserFilter, opts FindOptions) ([]model.User, error)

func (*UserDAO) Get

func (dao *UserDAO) Get(ctx context.Context, id model.ID) (model.User, error)

func (*UserDAO) Insert

func (dao *UserDAO) Insert(ctx context.Context, dto InsertUserDTO) (model.ID, error)

func (*UserDAO) Update

func (dao *UserDAO) Update(ctx context.Context, id model.ID, dto UpdateUserDTO) error

Jump to

Keyboard shortcuts

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