database

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Database = dbUser
)

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, c pgconn.Config) (*pgxpool.Pool, error)

func CreateTableIfNotExists

func CreateTableIfNotExists(ctx context.Context, conn *pgxpool.Pool) error

Types

type ConnectFunc

type ConnectFunc func(tb testing.TB, ctx context.Context, exclusive bool) *pgxpool.Pool

func InitDatabase

func InitDatabase(ctx context.Context) (_ ConnectFunc, _ func(), err error)

type CreateEmployeeParams

type CreateEmployeeParams struct {
	Username string `db:"username"`
	Name     string `db:"name"`
	TenantID int32  `db:"tenant_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 Employee

type Employee struct {
	ID       int32  `db:"id"`
	Username string `db:"username"`
	Name     string `db:"name"`
	TenantID int32  `db:"tenant_id"`
}

type GetEmployeesParams

type GetEmployeesParams struct {
	TenantID int32 `db:"tenant_id"`
	ID       int32 `db:"id"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ClearEmployees

func (q *Queries) ClearEmployees(ctx context.Context) error

func (*Queries) ClearTenants

func (q *Queries) ClearTenants(ctx context.Context) error

func (*Queries) CreateEmployee

func (q *Queries) CreateEmployee(ctx context.Context, arg CreateEmployeeParams) (Employee, error)

func (*Queries) CreateTenant

func (q *Queries) CreateTenant(ctx context.Context, name string) (Tenant, error)

func (*Queries) GetEmployees

func (q *Queries) GetEmployees(ctx context.Context, arg GetEmployeesParams) (Employee, error)

func (*Queries) GetTenant

func (q *Queries) GetTenant(ctx context.Context, id int32) (Tenant, error)

func (*Queries) ListEmployees

func (q *Queries) ListEmployees(ctx context.Context, tenantID int32) ([]Employee, error)

func (*Queries) ListTenants

func (q *Queries) ListTenants(ctx context.Context) ([]Tenant, error)

func (*Queries) WithTx

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

type Tenant

type Tenant struct {
	ID   int32  `db:"id"`
	Name string `db:"name"`
}

Jump to

Keyboard shortcuts

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