db

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsText

func AsText(s string) pgtype.Text

Types

type ChangePasswordParams

type ChangePasswordParams struct {
	PasswordHash pgtype.Text
	UserID       string
}

func GetChangePasswordParams

func GetChangePasswordParams(hash, uid string) ChangePasswordParams

type CreateSnippetParams

type CreateSnippetParams struct {
	SnippetID   string
	Title       pgtype.Text
	Content     pgtype.Text
	DateExpires pgtype.Timestamptz
	DateCreated pgtype.Timestamptz
	DateUpdated pgtype.Timestamptz
}

func GetCreateSnippetParams

func GetCreateSnippetParams(id, title, content string, exp, create, up time.Time) CreateSnippetParams

type CreateUserParams

type CreateUserParams struct {
	UserID       string
	Name         pgtype.Text
	Email        pgtype.Text
	Active       pgtype.Bool
	PasswordHash pgtype.Text
	Roles        []string
	DateCreated  pgtype.Timestamptz
	DateUpdated  pgtype.Timestamptz
}

func GetCreateUserParams

func GetCreateUserParams(id, name, email string, active bool,
	hash string, roles []string, create, up time.Time) CreateUserParams

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 Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ChangePassword

func (q *Queries) ChangePassword(ctx context.Context, arg ChangePasswordParams) error

func (*Queries) CreateSnippet

func (q *Queries) CreateSnippet(ctx context.Context, arg CreateSnippetParams) (Snippet, error)

func (*Queries) CreateUser

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

func (*Queries) DeleteSnippet

func (q *Queries) DeleteSnippet(ctx context.Context, snippetID string) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, userID string) error

func (*Queries) GetSnippet

func (q *Queries) GetSnippet(ctx context.Context, snippetID string) (Snippet, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, userID string) (User, error)

func (*Queries) GetUserByEmail

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

func (*Queries) ListLatestSnippets

func (q *Queries) ListLatestSnippets(ctx context.Context) ([]Snippet, error)

func (*Queries) ListSnippets

func (q *Queries) ListSnippets(ctx context.Context) ([]Snippet, error)

func (*Queries) ListUsers

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

func (*Queries) UpdateSnippet

func (q *Queries) UpdateSnippet(ctx context.Context, arg UpdateSnippetParams) error

func (*Queries) UpdateUser

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

func (*Queries) WithTx

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

type Snippet

type Snippet struct {
	SnippetID   string
	Title       pgtype.Text
	Content     pgtype.Text
	DateExpires pgtype.Timestamptz
	DateCreated pgtype.Timestamptz
	DateUpdated pgtype.Timestamptz
}

type UpdateSnippetParams

type UpdateSnippetParams struct {
	SnippetID   string
	Title       pgtype.Text
	Content     pgtype.Text
	DateExpires pgtype.Timestamptz
	DateUpdated pgtype.Timestamptz
}

func GetUpdateSnippetParams

func GetUpdateSnippetParams(id, title, content string, exp, up time.Time) UpdateSnippetParams

type UpdateUserParams

type UpdateUserParams struct {
	UserID       string
	Name         pgtype.Text
	Email        pgtype.Text
	Roles        []string
	PasswordHash pgtype.Text
	DateUpdated  pgtype.Timestamptz
}

func GetUpdateUserParams

func GetUpdateUserParams(id, name, email string, roles []string,
	hash string, up time.Time) UpdateUserParams

type User

type User struct {
	UserID       string
	Name         pgtype.Text
	Email        pgtype.Text
	Active       pgtype.Bool
	Roles        []string
	PasswordHash pgtype.Text
	DateCreated  pgtype.Timestamptz
	DateUpdated  pgtype.Timestamptz
}

Jump to

Keyboard shortcuts

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