postgresqlc

package
v0.0.0-...-29719d2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package postgresqlc contains raw SQL queries for the storage services and wrapper functions to use them.

Index

Constants

View Source
const (
	CodeTableNotFound   = "42P01"
	CodeUniqueViolation = "23505"
)

Variables

This section is empty.

Functions

func IsConstraintFailed

func IsConstraintFailed(err error) bool

IsConstraintFailed returns true if err is returned because of a unique constraint violation.

func IsErrorCode

func IsErrorCode(err error, code string) bool

IsErrorCode returns true if err is a PostgreSQL error with the given code.

func Migrate

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

Migrate runs all migrations on the database.

Types

type CreateUserParams

type CreateUserParams struct {
	Secret userservice.Secret
	Name   string
}

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 DeleteSessionParams

type DeleteSessionParams struct {
	UserSecret userservice.Secret
	ID         int64
}

type DeliveryMethod

type DeliveryMethod struct {
	ID          string
	Units       string
	Name        string
	Description string
}

type DosageHistory

type DosageHistory struct {
	UserSecret     userservice.Secret
	DeliveryMethod pgtype.Text
	Dose           float32
	TakenAt        pgtype.Timestamptz
	TakenOffAt     pgtype.Timestamptz
	Comment        pgtype.Text
}

type DosageSchedule

type DosageSchedule struct {
	UserSecret     userservice.Secret
	DeliveryMethod pgtype.Text
	Dose           float32
	Interval       pgtype.Interval
	Concurrence    pgtype.Int2
}

type DoseHistoryParams

type DoseHistoryParams struct {
	UserSecret userservice.Secret
	Start      pgtype.Timestamptz
	End        pgtype.Timestamptz
}

type DoseHistoryRows

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

func (*DoseHistoryRows) Close

func (r *DoseHistoryRows) Close()

func (*DoseHistoryRows) Err

func (r *DoseHistoryRows) Err() error

func (*DoseHistoryRows) Iterate

func (r *DoseHistoryRows) Iterate() iter.Seq[DosageHistory]

type EditDoseParams

type EditDoseParams struct {
	DeliveryMethod pgtype.Text
	Dose           float32
	TakenAt        pgtype.Timestamptz
	TakenOffAt     pgtype.Timestamptz
	UserSecret     userservice.Secret
	OldTakenAt     pgtype.Timestamptz
}

type ForgetDosesParams

type ForgetDosesParams struct {
	UserSecret userservice.Secret
	TakenAt    []pgtype.Timestamp
}

type Meta

type Meta struct {
	X bool
	V int16
}

type NotificationHistory

type NotificationHistory struct {
	NotificationID     pgtype.UUID
	UserSecret         userservice.Secret
	SupposedEntityTime pgtype.Timestamptz
	SentAt             pgtype.Timestamptz
	ErrorReason        pgtype.Text
	Errored            pgtype.Bool
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateUser

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

func (*Queries) DeleteDosageSchedule

func (q *Queries) DeleteDosageSchedule(ctx context.Context, userSecret userservice.Secret) error

func (*Queries) DeleteSession

func (q *Queries) DeleteSession(ctx context.Context, arg DeleteSessionParams) error

func (*Queries) DeliveryMethod

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

func (*Queries) DeliveryMethods

func (q *Queries) DeliveryMethods(ctx context.Context) ([]DeliveryMethod, error)

Language: postgresql

func (*Queries) DosageSchedule

func (q *Queries) DosageSchedule(ctx context.Context, userSecret userservice.Secret) (DosageSchedule, error)

func (*Queries) DoseHistory

func (q *Queries) DoseHistory(ctx context.Context, arg DoseHistoryParams) DoseHistoryRows

func (*Queries) EditDose

func (q *Queries) EditDose(ctx context.Context, arg EditDoseParams) (int64, error)

func (*Queries) ForgetDoses

func (q *Queries) ForgetDoses(ctx context.Context, arg ForgetDosesParams) (int64, error)

func (*Queries) ListSessions

func (q *Queries) ListSessions(ctx context.Context, userSecret userservice.Secret) ([]UserSession, error)

func (*Queries) RecordDose

func (q *Queries) RecordDose(ctx context.Context, arg RecordDoseParams) error

func (*Queries) RegisterSession

func (q *Queries) RegisterSession(ctx context.Context, arg RegisterSessionParams) error

func (*Queries) SetDosageSchedule

func (q *Queries) SetDosageSchedule(ctx context.Context, arg SetDosageScheduleParams) error

func (*Queries) SetUserNotificationPreferences

func (q *Queries) SetUserNotificationPreferences(ctx context.Context, arg SetUserNotificationPreferencesParams) error

func (*Queries) UpdateUserLocale

func (q *Queries) UpdateUserLocale(ctx context.Context, arg UpdateUserLocaleParams) error

func (*Queries) UpdateUserName

func (q *Queries) UpdateUserName(ctx context.Context, arg UpdateUserNameParams) error

func (*Queries) User

func (q *Queries) User(ctx context.Context, secret userservice.Secret) (User, error)

func (*Queries) UserNotificationPreferences

func (q *Queries) UserNotificationPreferences(ctx context.Context, secret userservice.Secret) (notificationservice.UserPreferences, error)

func (*Queries) ValidateSession

func (q *Queries) ValidateSession(ctx context.Context, token []byte) (UserSession, error)

func (*Queries) Version

func (q *Queries) Version(ctx context.Context) (int16, error)

func (*Queries) WithTx

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

type RecordDoseParams

type RecordDoseParams struct {
	UserSecret     userservice.Secret
	DeliveryMethod pgtype.Text
	Dose           float32
	TakenAt        pgtype.Timestamptz
	TakenOffAt     pgtype.Timestamptz
}

type RegisterSessionParams

type RegisterSessionParams struct {
	UserSecret userservice.Secret
	Token      []byte
	UserAgent  pgtype.Text
}

type SetDosageScheduleParams

type SetDosageScheduleParams struct {
	UserSecret     userservice.Secret
	DeliveryMethod pgtype.Text
	Dose           float32
	Interval       pgtype.Interval
	Concurrence    pgtype.Int2
}

type SetUserNotificationPreferencesParams

type SetUserNotificationPreferencesParams struct {
	Secret  userservice.Secret
	Column2 []byte
}

type UpdateUserLocaleParams

type UpdateUserLocaleParams struct {
	Secret userservice.Secret
	Locale userservice.Locale
}

type UpdateUserNameParams

type UpdateUserNameParams struct {
	Secret userservice.Secret
	Name   string
}

type User

type User struct {
	Secret                  userservice.Secret
	Name                    string
	Locale                  userservice.Locale
	RegisteredAt            pgtype.Timestamp
	NotificationPreferences notificationservice.UserPreferences
}

type UserSession

type UserSession struct {
	ID         int64
	UserSecret userservice.Secret
	Token      []byte
	CreatedAt  pgtype.Timestamp
	LastUsed   pgtype.Timestamp
	UserAgent  pgtype.Text
}

Jump to

Keyboard shortcuts

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