database

package
v0.0.0-...-a11af16 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrPgxNoRows

func IsErrPgxNoRows(err error) bool

func PointerToPgTypeInt4

func PointerToPgTypeInt4(num *int32) pgtype.Int4

func ToPgTypeInt4

func ToPgTypeInt4(num int32) pgtype.Int4

func ToPgTypeText

func ToPgTypeText(str string) pgtype.Text

func ToPgTypeTimestamp

func ToPgTypeTimestamp(t time.Time) pgtype.Timestamp

func ToPgTypeTimestamptz

func ToPgTypeTimestamptz(t time.Time) pgtype.Timestamptz

func UseTransaction

func UseTransaction(ctx context.Context, db *Service, fn func(queries *database_queries.Queries) error) error

Types

type ActiveGuestLoginIdentity

type ActiveGuestLoginIdentity struct {
	ID              int32              `json:"id"`
	LoginIdentityID int32              `json:"login_identity_id"`
	DeviceID        string             `json:"device_id"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	UpdatedAt       pgtype.Timestamptz `json:"updated_at"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveLoginIdentity

type ActiveLoginIdentity struct {
	ID           int32              `json:"id"`
	UserID       int32              `json:"user_id"`
	IdentityType string             `json:"identity_type"`
	IsPrimary    pgtype.Bool        `json:"is_primary"`
	LastUsedAt   pgtype.Timestamptz `json:"last_used_at"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveOauthConnection

type ActiveOauthConnection struct {
	ID           int32              `json:"id"`
	ProviderName string             `json:"provider_name"`
	Scopes       []string           `json:"scopes"`
	CreatedAt    pgtype.Timestamp   `json:"created_at"`
	UpdatedAt    pgtype.Timestamp   `json:"updated_at"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveOauthIntegration

type ActiveOauthIntegration struct {
	ID                int32              `json:"id"`
	OauthConnectionID int32              `json:"oauth_connection_id"`
	IntegrationType   string             `json:"integration_type"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveOauthProvider

type ActiveOauthProvider struct {
	Name          string             `json:"name"`
	IsOidcCapable bool               `json:"is_oidc_capable"`
	CreatedAt     pgtype.Timestamp   `json:"created_at"`
	UpdatedAt     pgtype.Timestamp   `json:"updated_at"`
	DeletedAt     pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveOauthToken

type ActiveOauthToken struct {
	ID                 int32              `json:"id"`
	OauthIntegrationID int32              `json:"oauth_integration_id"`
	AccessToken        string             `json:"access_token"`
	RefreshToken       pgtype.Text        `json:"refresh_token"`
	TokenType          string             `json:"token_type"`
	ExpiresAt          pgtype.Timestamp   `json:"expires_at"`
	IssuedAt           pgtype.Timestamp   `json:"issued_at"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveOidcLoginIdentity

type ActiveOidcLoginIdentity struct {
	ID                        int32              `json:"id"`
	LoginIdentityID           int32              `json:"login_identity_id"`
	OidcUserIntegrationDataID int32              `json:"oidc_user_integration_data_id"`
	CreatedAt                 pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                 pgtype.Timestamptz `json:"updated_at"`
	DeletedAt                 pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveOidcUserIntegrationDatum

type ActiveOidcUserIntegrationDatum struct {
	ID                int32              `json:"id"`
	UserIntegrationID int32              `json:"user_integration_id"`
	Sub               string             `json:"sub"`
	Email             pgtype.Text        `json:"email"`
	Iss               string             `json:"iss"`
	Aud               string             `json:"aud"`
	GivenName         pgtype.Text        `json:"given_name"`
	FamilyName        pgtype.Text        `json:"family_name"`
	Name              pgtype.Text        `json:"name"`
	Picture           pgtype.Text        `json:"picture"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
}

type ActivePasswordLoginIdentity

type ActivePasswordLoginIdentity struct {
	ID              int32              `json:"id"`
	LoginIdentityID int32              `json:"login_identity_id"`
	Email           pgtype.Text        `json:"email"`
	Phone           pgtype.Text        `json:"phone"`
	HashedPass      string             `json:"hashed_pass"`
	PassSalt        string             `json:"pass_salt"`
	VerifiedAt      pgtype.Timestamptz `json:"verified_at"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	UpdatedAt       pgtype.Timestamptz `json:"updated_at"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveSession

type ActiveSession struct {
	ID               int32              `json:"id"`
	Token            string             `json:"token"`
	IpAddress        netip.Addr         `json:"ip_address"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
	ExpiresAt        pgtype.Timestamptz `json:"expires_at"`
	DeletedAt        pgtype.Timestamptz `json:"deleted_at"`
	OriginatedFrom   int32              `json:"originated_from"`
	UsedInstallation int32              `json:"used_installation"`
}

type ActiveSystemIntegration

type ActiveSystemIntegration struct {
	ID                 int32              `json:"id"`
	OauthIntegrationID int32              `json:"oauth_integration_id"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

type ActiveUserIntegration

type ActiveUserIntegration struct {
	ID                 int32              `json:"id"`
	OauthIntegrationID int32              `json:"oauth_integration_id"`
	UserID             int32              `json:"user_id"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

type GuestLoginIdentity

type GuestLoginIdentity struct {
	ID              int32              `json:"id"`
	LoginIdentityID int32              `json:"login_identity_id"`
	DeviceID        string             `json:"device_id"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	UpdatedAt       pgtype.Timestamptz `json:"updated_at"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
}

type Installation

type Installation struct {
	ID                      int32              `json:"id"`
	InstallationToken       string             `json:"installation_token"`
	NotificationToken       pgtype.Text        `json:"notification_token"`
	Locale                  string             `json:"locale"`
	TimezoneOffsetInMinutes int32              `json:"timezone_offset_in_minutes"`
	DeviceManufacturer      pgtype.Text        `json:"device_manufacturer"`
	DeviceOs                pgtype.Text        `json:"device_os"`
	DeviceOsVersion         pgtype.Text        `json:"device_os_version"`
	AppVersion              string             `json:"app_version"`
	CreatedAt               pgtype.Timestamptz `json:"created_at"`
	UpdatedAt               pgtype.Timestamptz `json:"updated_at"`
	DeletedAt               pgtype.Timestamptz `json:"deleted_at"`
	AttachTo                pgtype.Int4        `json:"attach_to"`
	LastAttachTo            pgtype.Int4        `json:"last_attach_to"`
}

type LoginIdentity

type LoginIdentity struct {
	ID           int32              `json:"id"`
	UserID       int32              `json:"user_id"`
	IdentityType string             `json:"identity_type"`
	IsPrimary    pgtype.Bool        `json:"is_primary"`
	LastUsedAt   pgtype.Timestamptz `json:"last_used_at"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
}

type NotDeletedUser

type NotDeletedUser struct {
	ID           int32              `json:"id"`
	Username     string             `json:"username"`
	ProfileImage pgtype.Text        `json:"profile_image"`
	FirstName    string             `json:"first_name"`
	MiddleName   pgtype.Text        `json:"middle_name"`
	LastName     pgtype.Text        `json:"last_name"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
	BlockedAt    pgtype.Timestamptz `json:"blocked_at"`
	BlockedUntil pgtype.Timestamptz `json:"blocked_until"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
	RoleID       pgtype.Int4        `json:"role_id"`
}

type OauthConnection

type OauthConnection struct {
	ID           int32              `json:"id"`
	ProviderName string             `json:"provider_name"`
	Scopes       []string           `json:"scopes"`
	CreatedAt    pgtype.Timestamp   `json:"created_at"`
	UpdatedAt    pgtype.Timestamp   `json:"updated_at"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
}

type OauthIntegration

type OauthIntegration struct {
	ID                int32              `json:"id"`
	OauthConnectionID int32              `json:"oauth_connection_id"`
	IntegrationType   string             `json:"integration_type"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
}

type OauthProvider

type OauthProvider struct {
	Name          string             `json:"name"`
	IsOidcCapable bool               `json:"is_oidc_capable"`
	CreatedAt     pgtype.Timestamp   `json:"created_at"`
	UpdatedAt     pgtype.Timestamp   `json:"updated_at"`
	DeletedAt     pgtype.Timestamptz `json:"deleted_at"`
}

type OauthToken

type OauthToken struct {
	ID                 int32              `json:"id"`
	OauthIntegrationID int32              `json:"oauth_integration_id"`
	AccessToken        string             `json:"access_token"`
	RefreshToken       pgtype.Text        `json:"refresh_token"`
	TokenType          string             `json:"token_type"`
	ExpiresAt          pgtype.Timestamp   `json:"expires_at"`
	IssuedAt           pgtype.Timestamp   `json:"issued_at"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

type OidcLoginIdentity

type OidcLoginIdentity struct {
	ID                        int32              `json:"id"`
	LoginIdentityID           int32              `json:"login_identity_id"`
	OidcUserIntegrationDataID int32              `json:"oidc_user_integration_data_id"`
	CreatedAt                 pgtype.Timestamptz `json:"created_at"`
	UpdatedAt                 pgtype.Timestamptz `json:"updated_at"`
	DeletedAt                 pgtype.Timestamptz `json:"deleted_at"`
}

type OidcUserIntegrationDatum

type OidcUserIntegrationDatum struct {
	ID                int32              `json:"id"`
	UserIntegrationID int32              `json:"user_integration_id"`
	Sub               string             `json:"sub"`
	Email             pgtype.Text        `json:"email"`
	Iss               string             `json:"iss"`
	Aud               string             `json:"aud"`
	GivenName         pgtype.Text        `json:"given_name"`
	FamilyName        pgtype.Text        `json:"family_name"`
	Name              pgtype.Text        `json:"name"`
	Picture           pgtype.Text        `json:"picture"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
}

type PasswordLoginIdentity

type PasswordLoginIdentity struct {
	ID              int32              `json:"id"`
	LoginIdentityID int32              `json:"login_identity_id"`
	Email           pgtype.Text        `json:"email"`
	Phone           pgtype.Text        `json:"phone"`
	HashedPass      string             `json:"hashed_pass"`
	PassSalt        string             `json:"pass_salt"`
	VerifiedAt      pgtype.Timestamptz `json:"verified_at"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	UpdatedAt       pgtype.Timestamptz `json:"updated_at"`
	DeletedAt       pgtype.Timestamptz `json:"deleted_at"`
}

type Permission

type Permission struct {
	ID        int32              `json:"id"`
	Name      string             `json:"name"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}

type Role

type Role struct {
	ID        int32              `json:"id"`
	Name      string             `json:"name"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}

type RolePermission

type RolePermission struct {
	RoleID       int32              `json:"role_id"`
	PermissionID int32              `json:"permission_id"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

type Service

type Service struct {
	ConnPool *pgxpool.Pool
	Queries  *database_queries.Queries
}

func NewConnection

func NewConnection(ctx context.Context) *Service

func (*Service) Close

func (s *Service) Close(ctx context.Context)

Close closes the database connection. It logs a message indicating the disconnection from the specific database.

func (*Service) Health

func (s *Service) Health(ctx context.Context) map[string]string

Health checks the health of the database connection by pinging the database. It returns a map with keys indicating various health statistics.

type Session

type Session struct {
	ID               int32              `json:"id"`
	Token            string             `json:"token"`
	IpAddress        netip.Addr         `json:"ip_address"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
	ExpiresAt        pgtype.Timestamptz `json:"expires_at"`
	DeletedAt        pgtype.Timestamptz `json:"deleted_at"`
	OriginatedFrom   int32              `json:"originated_from"`
	UsedInstallation int32              `json:"used_installation"`
}

type SystemIntegration

type SystemIntegration struct {
	ID                 int32              `json:"id"`
	OauthIntegrationID int32              `json:"oauth_integration_id"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

type Todo

type Todo struct {
	ID        int32              `json:"id"`
	Title     string             `json:"title"`
	Body      string             `json:"body"`
	Status    string             `json:"status"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
	UserID    int32              `json:"user_id"`
}

type User

type User struct {
	ID           int32              `json:"id"`
	Username     string             `json:"username"`
	ProfileImage pgtype.Text        `json:"profile_image"`
	FirstName    string             `json:"first_name"`
	MiddleName   pgtype.Text        `json:"middle_name"`
	LastName     pgtype.Text        `json:"last_name"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
	BlockedAt    pgtype.Timestamptz `json:"blocked_at"`
	BlockedUntil pgtype.Timestamptz `json:"blocked_until"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
	RoleID       pgtype.Int4        `json:"role_id"`
}

type UserIntegration

type UserIntegration struct {
	ID                 int32              `json:"id"`
	OauthIntegrationID int32              `json:"oauth_integration_id"`
	UserID             int32              `json:"user_id"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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