db

package
v0.0.0-...-16e7fcc Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Absence

type Absence struct {
	ID           int64      `json:"id"`
	UserID       int64      `json:"user_id"`
	StartTime    time.Time  `json:"start_time"`
	EndTime      *time.Time `json:"end_time"`
	Reason       string     `json:"reason"`
	Paid         bool       `json:"paid"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    *time.Time `json:"updated_at"`
	ApprovedByID *int64     `json:"approved_by_id"`
}

type Company

type Company struct {
	ID        int64      `json:"id"`
	Name      string     `json:"name"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

type CreateAbsenceParams

type CreateAbsenceParams struct {
	UserID       int64      `json:"user_id"`
	StartTime    time.Time  `json:"start_time"`
	EndTime      *time.Time `json:"end_time"`
	Reason       string     `json:"reason"`
	Paid         bool       `json:"paid"`
	ApprovedByID *int64     `json:"approved_by_id"`
}

type CreateEntryParams

type CreateEntryParams struct {
	UserID    int64      `json:"user_id"`
	StartTime time.Time  `json:"start_time"`
	EndTime   *time.Time `json:"end_time"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	Username     string    `json:"username"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type CreateTeamParams

type CreateTeamParams struct {
	Name      string `json:"name"`
	ManagerID *int64 `json:"manager_id"`
}

type CreateUserParams

type CreateUserParams struct {
	Username  string    `json:"username"`
	Password  string    `json:"password"`
	Email     string    `json:"email"`
	Name      string    `json:"name"`
	Surname   string    `json:"surname"`
	BirthDate time.Time `json:"birth_date"`
	Gender    string    `json:"gender"`
	Language  string    `json:"language"`
	Country   *string   `json:"country"`
	Timezone  string    `json:"timezone"`
	CompanyID *int64    `json:"company_id"`
	ManagerID *int64    `json:"manager_id"`
	TeamID    *int64    `json:"team_id"`
}

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 Entry

type Entry struct {
	ID        int64      `json:"id"`
	UserID    int64      `json:"user_id"`
	StartTime time.Time  `json:"start_time"`
	EndTime   *time.Time `json:"end_time"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

type ListAbsencesParams

type ListAbsencesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListCompaniesParams

type ListCompaniesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListCompanyEmployeesParams

type ListCompanyEmployeesParams struct {
	ID     int64 `json:"id"`
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListEntriesParams

type ListEntriesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListTeamMembersParams

type ListTeamMembersParams struct {
	TeamID *int64 `json:"team_id"`
	Limit  int32  `json:"limit"`
	Offset int32  `json:"offset"`
}

type ListTeamsParams

type ListTeamsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListUserAbsencesParams

type ListUserAbsencesParams struct {
	UserID int64 `json:"user_id"`
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListUserEntriesParams

type ListUserEntriesParams struct {
	UserID int64 `json:"user_id"`
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type Querier

type Querier interface {
	CreateAbsence(ctx context.Context, arg CreateAbsenceParams) (Absence, error)
	CreateCompany(ctx context.Context, name string) (Company, error)
	CreateEntry(ctx context.Context, arg CreateEntryParams) (Entry, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateTeam(ctx context.Context, arg CreateTeamParams) (Team, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteAbsence(ctx context.Context, id int64) (Absence, error)
	DeleteCompany(ctx context.Context, id int64) (Company, error)
	DeleteEntry(ctx context.Context, id int64) (Entry, error)
	DeleteTeam(ctx context.Context, id int64) (Team, error)
	DeleteUser(ctx context.Context, id int64) (User, error)
	GetAbsence(ctx context.Context, id int64) (Absence, error)
	GetCompany(ctx context.Context, id int64) (Company, error)
	GetEntry(ctx context.Context, id int64) (Entry, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetTeam(ctx context.Context, id int64) (Team, error)
	GetUser(ctx context.Context, id int64) (User, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	ListAbsences(ctx context.Context, arg ListAbsencesParams) ([]Absence, error)
	ListCompanies(ctx context.Context, arg ListCompaniesParams) ([]Company, error)
	ListCompanyEmployees(ctx context.Context, arg ListCompanyEmployeesParams) ([]User, error)
	ListEntries(ctx context.Context, arg ListEntriesParams) ([]Entry, error)
	ListTeamMembers(ctx context.Context, arg ListTeamMembersParams) ([]User, error)
	ListTeams(ctx context.Context, arg ListTeamsParams) ([]Team, error)
	ListUserAbsences(ctx context.Context, arg ListUserAbsencesParams) ([]Absence, error)
	ListUserEntries(ctx context.Context, arg ListUserEntriesParams) ([]Entry, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
	UpdateAbsence(ctx context.Context, arg UpdateAbsenceParams) (Absence, error)
	UpdateCompany(ctx context.Context, arg UpdateCompanyParams) (Company, error)
	UpdateEntry(ctx context.Context, arg UpdateEntryParams) (Entry, error)
	UpdateTeam(ctx context.Context, arg UpdateTeamParams) (Team, error)
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateAbsence

func (q *Queries) CreateAbsence(ctx context.Context, arg CreateAbsenceParams) (Absence, error)

func (*Queries) CreateCompany

func (q *Queries) CreateCompany(ctx context.Context, name string) (Company, error)

func (*Queries) CreateEntry

func (q *Queries) CreateEntry(ctx context.Context, arg CreateEntryParams) (Entry, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) CreateTeam

func (q *Queries) CreateTeam(ctx context.Context, arg CreateTeamParams) (Team, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteAbsence

func (q *Queries) DeleteAbsence(ctx context.Context, id int64) (Absence, error)

func (*Queries) DeleteCompany

func (q *Queries) DeleteCompany(ctx context.Context, id int64) (Company, error)

func (*Queries) DeleteEntry

func (q *Queries) DeleteEntry(ctx context.Context, id int64) (Entry, error)

func (*Queries) DeleteTeam

func (q *Queries) DeleteTeam(ctx context.Context, id int64) (Team, error)

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetAbsence

func (q *Queries) GetAbsence(ctx context.Context, id int64) (Absence, error)

func (*Queries) GetCompany

func (q *Queries) GetCompany(ctx context.Context, id int64) (Company, error)

func (*Queries) GetEntry

func (q *Queries) GetEntry(ctx context.Context, id int64) (Entry, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)

func (*Queries) GetTeam

func (q *Queries) GetTeam(ctx context.Context, id int64) (Team, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserByEmail

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

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) ListAbsences

func (q *Queries) ListAbsences(ctx context.Context, arg ListAbsencesParams) ([]Absence, error)

func (*Queries) ListCompanies

func (q *Queries) ListCompanies(ctx context.Context, arg ListCompaniesParams) ([]Company, error)

func (*Queries) ListCompanyEmployees

func (q *Queries) ListCompanyEmployees(ctx context.Context, arg ListCompanyEmployeesParams) ([]User, error)

func (*Queries) ListEntries

func (q *Queries) ListEntries(ctx context.Context, arg ListEntriesParams) ([]Entry, error)

func (*Queries) ListTeamMembers

func (q *Queries) ListTeamMembers(ctx context.Context, arg ListTeamMembersParams) ([]User, error)

func (*Queries) ListTeams

func (q *Queries) ListTeams(ctx context.Context, arg ListTeamsParams) ([]Team, error)

func (*Queries) ListUserAbsences

func (q *Queries) ListUserAbsences(ctx context.Context, arg ListUserAbsencesParams) ([]Absence, error)

func (*Queries) ListUserEntries

func (q *Queries) ListUserEntries(ctx context.Context, arg ListUserEntriesParams) ([]Entry, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) UpdateAbsence

func (q *Queries) UpdateAbsence(ctx context.Context, arg UpdateAbsenceParams) (Absence, error)

func (*Queries) UpdateCompany

func (q *Queries) UpdateCompany(ctx context.Context, arg UpdateCompanyParams) (Company, error)

func (*Queries) UpdateEntry

func (q *Queries) UpdateEntry(ctx context.Context, arg UpdateEntryParams) (Entry, error)

func (*Queries) UpdateTeam

func (q *Queries) UpdateTeam(ctx context.Context, arg UpdateTeamParams) (Team, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) WithTx

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

type SQLStore

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

func (SQLStore) SeedDatabase

func (store SQLStore) SeedDatabase(ctx context.Context, config config.Config) error

type Session

type Session struct {
	ID           uuid.UUID `json:"id"`
	Username     string    `json:"username"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
	CreatedAt    time.Time `json:"created_at"`
}

type Store

type Store interface {
	Querier
	SeedDatabase(ctx context.Context, config config.Config) error
}

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

type Team

type Team struct {
	ID        int64      `json:"id"`
	Name      string     `json:"name"`
	ManagerID *int64     `json:"manager_id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

type UpdateAbsenceParams

type UpdateAbsenceParams struct {
	ID           int64      `json:"id"`
	UserID       int64      `json:"user_id"`
	Reason       string     `json:"reason"`
	Paid         bool       `json:"paid"`
	StartTime    time.Time  `json:"start_time"`
	EndTime      *time.Time `json:"end_time"`
	ApprovedByID *int64     `json:"approved_by_id"`
}

type UpdateCompanyParams

type UpdateCompanyParams struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type UpdateEntryParams

type UpdateEntryParams struct {
	ID        int64      `json:"id"`
	UserID    int64      `json:"user_id"`
	StartTime time.Time  `json:"start_time"`
	EndTime   *time.Time `json:"end_time"`
}

type UpdateTeamParams

type UpdateTeamParams struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	ManagerID *int64 `json:"manager_id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	Name      *string    `json:"name"`
	Surname   *string    `json:"surname"`
	Gender    *string    `json:"gender"`
	BirthDate *time.Time `json:"birth_date"`
	Language  *string    `json:"language"`
	Country   *string    `json:"country"`
	ID        int64      `json:"id"`
}

type User

type User struct {
	ID        int64      `json:"id"`
	Username  string     `json:"username"`
	Email     string     `json:"email"`
	Name      string     `json:"name"`
	Surname   string     `json:"surname"`
	CompanyID *int64     `json:"company_id"`
	Password  string     `json:"password"`
	Gender    string     `json:"gender"`
	BirthDate time.Time  `json:"birth_date"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
	// ISO-2 language code
	Language string `json:"language"`
	// ISO-2 Country code
	Country *string `json:"country"`
	// Timezone name
	Timezone  string `json:"timezone"`
	ManagerID *int64 `json:"manager_id"`
	TeamID    *int64 `json:"team_id"`
	Role      string `json:"role"`
}

Jump to

Keyboard shortcuts

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