database

package
v0.0.0-...-a1674a2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CategoryType

type CategoryType string
const (
	CategoryTypeElectronics   CategoryType = "electronics"
	CategoryTypeEntertainment CategoryType = "entertainment"
	CategoryTypeEducation     CategoryType = "education"
	CategoryTypeClothing      CategoryType = "clothing"
	CategoryTypeWork          CategoryType = "work"
	CategoryTypeSports        CategoryType = "sports"
)

func (*CategoryType) Scan

func (e *CategoryType) Scan(src interface{}) error

type CreateOAuthUserParams

type CreateOAuthUserParams struct {
	Username string      `json:"username"`
	Email    string      `json:"email"`
	Name     pgtype.Text `json:"name"`
	GoogleID pgtype.Text `json:"google_id"`
}

type CreatePaymentParams

type CreatePaymentParams struct {
	UserID     int32             `json:"user_id"`
	Name       string            `json:"name"`
	Amount     pgtype.Numeric    `json:"amount"`
	Type       TransactionType   `json:"type"`
	Category   CategoryType      `json:"category"`
	Date       string            `json:"date"`
	DueDate    pgtype.Text       `json:"due_date"`
	Paid       bool              `json:"paid"`
	PaidAt     pgtype.Text       `json:"paid_at"`
	Recurrent  bool              `json:"recurrent"`
	Frequency  NullFrequencyType `json:"frequency"`
	ReceiptUrl pgtype.Text       `json:"receipt_url"`
}

type CreateUserParams

type CreateUserParams struct {
	Username     string      `json:"username"`
	Email        string      `json:"email"`
	PasswordHash pgtype.Text `json:"password_hash"`
}

type CreateUserTokenParams

type CreateUserTokenParams struct {
	UserID    int32              `json:"user_id"`
	TokenHash string             `json:"token_hash"`
	Purpose   TokenPurpose       `json:"purpose"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
}

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 DeleteByUserAndPurposeParams

type DeleteByUserAndPurposeParams struct {
	UserID  int32        `json:"user_id"`
	Purpose TokenPurpose `json:"purpose"`
}

type FrequencyType

type FrequencyType string
const (
	FrequencyTypeDaily   FrequencyType = "daily"
	FrequencyTypeWeekly  FrequencyType = "weekly"
	FrequencyTypeMonthly FrequencyType = "monthly"
	FrequencyTypeYearly  FrequencyType = "yearly"
)

func (*FrequencyType) Scan

func (e *FrequencyType) Scan(src interface{}) error

type GetAllPaymentsParams

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

type GetAllUsersParams

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

type GetTokenByHashParams

type GetTokenByHashParams struct {
	TokenHash string       `json:"token_hash"`
	Purpose   TokenPurpose `json:"purpose"`
}

type NullCategoryType

type NullCategoryType struct {
	CategoryType CategoryType `json:"category_type"`
	Valid        bool         `json:"valid"` // Valid is true if CategoryType is not NULL
}

func (*NullCategoryType) Scan

func (ns *NullCategoryType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullCategoryType) Value

func (ns NullCategoryType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullFrequencyType

type NullFrequencyType struct {
	FrequencyType FrequencyType `json:"frequency_type"`
	Valid         bool          `json:"valid"` // Valid is true if FrequencyType is not NULL
}

func (*NullFrequencyType) Scan

func (ns *NullFrequencyType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullFrequencyType) Value

func (ns NullFrequencyType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTokenPurpose

type NullTokenPurpose struct {
	TokenPurpose TokenPurpose `json:"token_purpose"`
	Valid        bool         `json:"valid"` // Valid is true if TokenPurpose is not NULL
}

func (*NullTokenPurpose) Scan

func (ns *NullTokenPurpose) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTokenPurpose) Value

func (ns NullTokenPurpose) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTransactionType

type NullTransactionType struct {
	TransactionType TransactionType `json:"transaction_type"`
	Valid           bool            `json:"valid"` // Valid is true if TransactionType is not NULL
}

func (*NullTransactionType) Scan

func (ns *NullTransactionType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTransactionType) Value

func (ns NullTransactionType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUserRole

type NullUserRole struct {
	UserRole UserRole `json:"user_role"`
	Valid    bool     `json:"valid"` // Valid is true if UserRole is not NULL
}

func (*NullUserRole) Scan

func (ns *NullUserRole) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUserRole) Value

func (ns NullUserRole) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Payment

type Payment struct {
	ID         int32             `json:"id"`
	UserID     int32             `json:"user_id"`
	Name       string            `json:"name"`
	Amount     pgtype.Numeric    `json:"amount"`
	Type       TransactionType   `json:"type"`
	Category   CategoryType      `json:"category"`
	Date       string            `json:"date"`
	DueDate    pgtype.Text       `json:"due_date"`
	Paid       bool              `json:"paid"`
	PaidAt     pgtype.Text       `json:"paid_at"`
	Recurrent  bool              `json:"recurrent"`
	Frequency  NullFrequencyType `json:"frequency"`
	ReceiptUrl pgtype.Text       `json:"receipt_url"`
}

type Querier

type Querier interface {
	CreateOAuthUser(ctx context.Context, arg CreateOAuthUserParams) (User, error)
	CreatePayment(ctx context.Context, arg CreatePaymentParams) (Payment, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	CreateUserToken(ctx context.Context, arg CreateUserTokenParams) (UserToken, error)
	DeleteByUserAndPurpose(ctx context.Context, arg DeleteByUserAndPurposeParams) error
	DeleteOldTokens(ctx context.Context) (int64, error)
	DeletePayment(ctx context.Context, id int32) (int64, error)
	DeleteUser(ctx context.Context, id int32) (int64, error)
	GetAllPayments(ctx context.Context, arg GetAllPaymentsParams) ([]Payment, error)
	GetAllUsers(ctx context.Context, arg GetAllUsersParams) ([]User, error)
	GetMyPayments(ctx context.Context, userID int32) ([]Payment, error)
	GetPaymentByID(ctx context.Context, id int32) (Payment, error)
	GetTokenByHash(ctx context.Context, arg GetTokenByHashParams) (UserToken, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserByGoogleID(ctx context.Context, googleID pgtype.Text) (User, error)
	GetUserByID(ctx context.Context, id int32) (User, error)
	UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (int64, error)
	UpdateUserGoogleID(ctx context.Context, arg UpdateUserGoogleIDParams) (int64, error)
	UpdateUserIsActiveReturning(ctx context.Context, arg UpdateUserIsActiveReturningParams) (User, error)
	UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) (int64, error)
	UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (int64, error)
	VerifyAndConsumeToken(ctx context.Context, arg VerifyAndConsumeTokenParams) (UserToken, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateOAuthUser

func (q *Queries) CreateOAuthUser(ctx context.Context, arg CreateOAuthUserParams) (User, error)

func (*Queries) CreatePayment

func (q *Queries) CreatePayment(ctx context.Context, arg CreatePaymentParams) (Payment, error)

func (*Queries) CreateUser

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

func (*Queries) CreateUserToken

func (q *Queries) CreateUserToken(ctx context.Context, arg CreateUserTokenParams) (UserToken, error)

func (*Queries) DeleteByUserAndPurpose

func (q *Queries) DeleteByUserAndPurpose(ctx context.Context, arg DeleteByUserAndPurposeParams) error

func (*Queries) DeleteOldTokens

func (q *Queries) DeleteOldTokens(ctx context.Context) (int64, error)

func (*Queries) DeletePayment

func (q *Queries) DeletePayment(ctx context.Context, id int32) (int64, error)

func (*Queries) DeleteUser

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

func (*Queries) GetAllPayments

func (q *Queries) GetAllPayments(ctx context.Context, arg GetAllPaymentsParams) ([]Payment, error)

func (*Queries) GetAllUsers

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

func (*Queries) GetMyPayments

func (q *Queries) GetMyPayments(ctx context.Context, userID int32) ([]Payment, error)

func (*Queries) GetPaymentByID

func (q *Queries) GetPaymentByID(ctx context.Context, id int32) (Payment, error)

func (*Queries) GetTokenByHash

func (q *Queries) GetTokenByHash(ctx context.Context, arg GetTokenByHashParams) (UserToken, error)

func (*Queries) GetUserByEmail

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

func (*Queries) GetUserByGoogleID

func (q *Queries) GetUserByGoogleID(ctx context.Context, googleID pgtype.Text) (User, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id int32) (User, error)

func (*Queries) UpdatePayment

func (q *Queries) UpdatePayment(ctx context.Context, arg UpdatePaymentParams) (int64, error)

func (*Queries) UpdateUserGoogleID

func (q *Queries) UpdateUserGoogleID(ctx context.Context, arg UpdateUserGoogleIDParams) (int64, error)

func (*Queries) UpdateUserIsActiveReturning

func (q *Queries) UpdateUserIsActiveReturning(ctx context.Context, arg UpdateUserIsActiveReturningParams) (User, error)

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) (int64, error)

func (*Queries) UpdateUserProfile

func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (int64, error)

func (*Queries) VerifyAndConsumeToken

func (q *Queries) VerifyAndConsumeToken(ctx context.Context, arg VerifyAndConsumeTokenParams) (UserToken, error)

func (*Queries) WithTx

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

type TokenPurpose

type TokenPurpose string
const (
	TokenPurposeEmailVerification TokenPurpose = "email_verification"
	TokenPurposePasswordReset     TokenPurpose = "password_reset"
)

func (*TokenPurpose) Scan

func (e *TokenPurpose) Scan(src interface{}) error

type TransactionType

type TransactionType string
const (
	TransactionTypeExpense      TransactionType = "expense"
	TransactionTypeIncome       TransactionType = "income"
	TransactionTypeSubscription TransactionType = "subscription"
)

func (*TransactionType) Scan

func (e *TransactionType) Scan(src interface{}) error

type UpdatePaymentParams

type UpdatePaymentParams struct {
	ID         int32             `json:"id"`
	Name       string            `json:"name"`
	Amount     pgtype.Numeric    `json:"amount"`
	Type       TransactionType   `json:"type"`
	Category   CategoryType      `json:"category"`
	Date       string            `json:"date"`
	DueDate    pgtype.Text       `json:"due_date"`
	Paid       bool              `json:"paid"`
	PaidAt     pgtype.Text       `json:"paid_at"`
	Recurrent  bool              `json:"recurrent"`
	Frequency  NullFrequencyType `json:"frequency"`
	ReceiptUrl pgtype.Text       `json:"receipt_url"`
}

type UpdateUserGoogleIDParams

type UpdateUserGoogleIDParams struct {
	ID       int32       `json:"id"`
	GoogleID pgtype.Text `json:"google_id"`
}

type UpdateUserIsActiveReturningParams

type UpdateUserIsActiveReturningParams struct {
	ID       int32 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	ID           int32       `json:"id"`
	PasswordHash pgtype.Text `json:"password_hash"`
}

type UpdateUserProfileParams

type UpdateUserProfileParams struct {
	ID       int32  `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
}

type User

type User struct {
	ID           int32              `json:"id"`
	Username     string             `json:"username"`
	Email        string             `json:"email"`
	PasswordHash pgtype.Text        `json:"password_hash"`
	Name         pgtype.Text        `json:"name"`
	Role         UserRole           `json:"role"`
	GoogleID     pgtype.Text        `json:"google_id"`
	IsActive     bool               `json:"is_active"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
}

type UserRole

type UserRole string
const (
	UserRoleUser  UserRole = "user"
	UserRoleAdmin UserRole = "admin"
)

func (*UserRole) Scan

func (e *UserRole) Scan(src interface{}) error

type UserToken

type UserToken struct {
	ID        int32              `json:"id"`
	UserID    int32              `json:"user_id"`
	TokenHash string             `json:"token_hash"`
	Purpose   TokenPurpose       `json:"purpose"`
	Used      bool               `json:"used"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type VerifyAndConsumeTokenParams

type VerifyAndConsumeTokenParams struct {
	TokenHash string       `json:"token_hash"`
	Purpose   TokenPurpose `json:"purpose"`
}

Jump to

Keyboard shortcuts

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