database

package
v0.0.0-...-26cacaa Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 Installation

type Installation struct {
	ID                      int32              `json:"id"`
	InstallationID          uuid.UUID          `json:"installation_id"`
	NotificationToken       pgtype.Text        `json:"notification_token"`
	Locale                  string             `json:"locale"`
	TimezoneOffsetInMinutes int32              `json:"timezone_offset_in_minutes"`
	DeviceManufacturer      string             `json:"device_manufacturer"`
	DeviceOs                string             `json:"device_os"`
	DeviceOsVersion         string             `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 InstallationCreateNewInstallationParams

type InstallationCreateNewInstallationParams struct {
	InstallationID     uuid.UUID   `json:"installation_id"`
	NotificationToken  pgtype.Text `json:"notification_token"`
	Locale             string      `json:"locale"`
	DeviceManufacturer string      `json:"device_manufacturer"`
	DeviceOs           string      `json:"device_os"`
	DeviceOsVersion    string      `json:"device_os_version"`
	AppVersion         string      `json:"app_version"`
}

type InstallationGetInstallationUsingUUIdAndWhereAttachToParams

type InstallationGetInstallationUsingUUIdAndWhereAttachToParams struct {
	InstallationID uuid.UUID   `json:"installation_id"`
	AttachTo       pgtype.Int4 `json:"attach_to"`
}

type InstallationUpdateInstallationParams

type InstallationUpdateInstallationParams struct {
	ID                      int32       `json:"id"`
	InstallationID          uuid.UUID   `json:"installation_id"`
	NotificationToken       pgtype.Text `json:"notification_token"`
	Locale                  string      `json:"locale"`
	TimezoneOffsetInMinutes int32       `json:"timezone_offset_in_minutes"`
}

type LoginOption

type LoginOption struct {
	ID          int32              `json:"id"`
	LoginMethod string             `json:"login_method"`
	AccessKey   string             `json:"access_key"`
	HashedPass  pgtype.Text        `json:"hashed_pass"`
	PassSalt    pgtype.Text        `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"`
	UserID      int32              `json:"user_id"`
}

type LoginOptionChangeAllPasswordsByUserIdParams

type LoginOptionChangeAllPasswordsByUserIdParams struct {
	UserID     int32       `json:"user_id"`
	HashedPass pgtype.Text `json:"hashed_pass"`
	PassSalt   pgtype.Text `json:"pass_salt"`
}

type LoginOptionCreateNewLoginOptionParams

type LoginOptionCreateNewLoginOptionParams struct {
	LoginMethod string             `json:"login_method"`
	AccessKey   string             `json:"access_key"`
	HashedPass  pgtype.Text        `json:"hashed_pass"`
	PassSalt    pgtype.Text        `json:"pass_salt"`
	VerifiedAt  pgtype.Timestamptz `json:"verified_at"`
	UserID      int32              `json:"user_id"`
}

type LoginOptionGetActiveLoginOptionParams

type LoginOptionGetActiveLoginOptionParams struct {
	LoginMethod string `json:"login_method"`
	AccessKey   string `json:"access_key"`
}

type LoginOptionGetActiveLoginOptionWithUserParams

type LoginOptionGetActiveLoginOptionWithUserParams struct {
	LoginMethod string `json:"login_method"`
	AccessKey   string `json:"access_key"`
}

type LoginOptionGetActiveLoginOptionWithUserRow

type LoginOptionGetActiveLoginOptionWithUserRow struct {
	LoginOptionID          int32              `json:"login_option_id"`
	LoginOptionLoginMethod string             `json:"login_option_login_method"`
	LoginOptionAccessKey   string             `json:"login_option_access_key"`
	LoginOptionHashedPass  pgtype.Text        `json:"login_option_hashed_pass"`
	LoginOptionPassSalt    pgtype.Text        `json:"login_option_pass_salt"`
	LoginOptionVerifiedAt  pgtype.Timestamptz `json:"login_option_verified_at"`
	LoginOptionCreatedAt   pgtype.Timestamptz `json:"login_option_created_at"`
	LoginOptionUpdatedAt   pgtype.Timestamptz `json:"login_option_updated_at"`
	LoginOptionDeletedAt   pgtype.Timestamptz `json:"login_option_deleted_at"`
	UserID                 int32              `json:"user_id"`
	UserUsername           string             `json:"user_username"`
	UserProfileImage       pgtype.Text        `json:"user_profile_image"`
	UserFirstName          string             `json:"user_first_name"`
	UserMiddleName         pgtype.Text        `json:"user_middle_name"`
	UserLastName           pgtype.Text        `json:"user_last_name"`
	UserCreatedAt          pgtype.Timestamptz `json:"user_created_at"`
	UserUpdatedAt          pgtype.Timestamptz `json:"user_updated_at"`
	UserBlockedAt          pgtype.Timestamptz `json:"user_blocked_at"`
	UserDeletedAt          pgtype.Timestamptz `json:"user_deleted_at"`
	UserRoleID             pgtype.Int4        `json:"user_role_id"`
}

type LoginOptionGetAllActiveByUserIdAndLoginMethodParams

type LoginOptionGetAllActiveByUserIdAndLoginMethodParams struct {
	LoginMethod string `json:"login_method"`
	UserID      int32  `json:"user_id"`
}

type OTPCreateNewOtpParams

type OTPCreateNewOtpParams struct {
	Code           string             `json:"code"`
	Intent         string             `json:"intent"`
	OtpFor         pgtype.Int4        `json:"otp_for"`
	UsingSessionID pgtype.Int4        `json:"using_session_id"`
	ExpiresAt      pgtype.Timestamptz `json:"expires_at"`
}

type OTPGetActiveOtpByIdPairedWithSessionIdParams

type OTPGetActiveOtpByIdPairedWithSessionIdParams struct {
	ID             int32       `json:"id"`
	UsingSessionID pgtype.Int4 `json:"using_session_id"`
}

type Otp

type Otp struct {
	ID             int32              `json:"id"`
	Code           string             `json:"code"`
	HitCount       int16              `json:"hit_count"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
	ExpiresAt      pgtype.Timestamptz `json:"expires_at"`
	DeletedAt      pgtype.Timestamptz `json:"deleted_at"`
	Intent         string             `json:"intent"`
	OtpFor         pgtype.Int4        `json:"otp_for"`
	UsingSessionID pgtype.Int4        `json:"using_session_id"`
}

type PerRollAddPermissionToRoleParams

type PerRollAddPermissionToRoleParams struct {
	RoleID       int32 `json:"role_id"`
	PermissionID int32 `json:"permission_id"`
}

type PerRollGetAllPermissionsRow

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

type PerRollGetAllRoleRow

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

type PerRollGetRoleWithItsPermissionsRow

type PerRollGetRoleWithItsPermissionsRow struct {
	RoleID         int32  `json:"role_id"`
	RoleName       string `json:"role_name"`
	PermissionID   int32  `json:"permission_id"`
	PermissionName string `json:"permission_name"`
}

type PerRollRemovePermissionFromRoleParams

type PerRollRemovePermissionFromRoleParams struct {
	RoleID       int32 `json:"role_id"`
	PermissionID int32 `json:"permission_id"`
}

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 Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) InstallationCreateNewInstallation

func (q *Queries) InstallationCreateNewInstallation(ctx context.Context, arg InstallationCreateNewInstallationParams) (Installation, error)

InstallationCreateNewInstallation

INSERT INTO installation (
        installation_id,
        notification_token,
        locale,
        device_manufacturer,
        device_os,
        device_os_version,
        app_version
    )
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, installation_id, notification_token, locale, timezone_offset_in_minutes, device_manufacturer, device_os, device_os_version, app_version, created_at, updated_at, deleted_at, attach_to, last_attach_to

func (*Queries) InstallationGetInstallationUsingUUID

func (q *Queries) InstallationGetInstallationUsingUUID(ctx context.Context, installationID uuid.UUID) (Installation, error)

InstallationGetInstallationUsingUUID

SELECT id, installation_id, notification_token, locale, timezone_offset_in_minutes, device_manufacturer, device_os, device_os_version, app_version, created_at, updated_at, deleted_at, attach_to, last_attach_to
FROM installation
WHERE installation_id = $1
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) InstallationGetInstallationUsingUUIdAndWhereAttachTo

func (q *Queries) InstallationGetInstallationUsingUUIdAndWhereAttachTo(ctx context.Context, arg InstallationGetInstallationUsingUUIdAndWhereAttachToParams) (Installation, error)

InstallationGetInstallationUsingUUIdAndWhereAttachTo

SELECT id, installation_id, notification_token, locale, timezone_offset_in_minutes, device_manufacturer, device_os, device_os_version, app_version, created_at, updated_at, deleted_at, attach_to, last_attach_to
FROM installation
WHERE installation_id = $1
    AND attach_to = $2
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) InstallationSoftDeleteInstallation

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

InstallationSoftDeleteInstallation

UPDATE installation
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) InstallationUpdateInstallation

func (q *Queries) InstallationUpdateInstallation(ctx context.Context, arg InstallationUpdateInstallationParams) error

InstallationUpdateInstallation

UPDATE installation
SET notification_token = $3,
    locale = $4,
    timezone_Offset_in_minutes = $5
WHERE id = $1
    AND installation_id = $2
    AND deleted_at IS NULL

func (*Queries) LoginOptionChangeAllPasswordsByUserId

func (q *Queries) LoginOptionChangeAllPasswordsByUserId(ctx context.Context, arg LoginOptionChangeAllPasswordsByUserIdParams) error

LoginOptionChangeAllPasswordsByUserId

UPDATE login_option
SET hashed_pass = $2,
    pass_salt = $3
WHERE user_id = $1
    AND hashed_pass IS NOT NULL

func (*Queries) LoginOptionCreateNewLoginOption

func (q *Queries) LoginOptionCreateNewLoginOption(ctx context.Context, arg LoginOptionCreateNewLoginOptionParams) (LoginOption, error)

LoginOptionCreateNewLoginOption

INSERT INTO login_option(
        login_method,
        access_key,
        hashed_pass,
        pass_salt,
        verified_at,
        user_id
    )
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id, login_method, access_key, hashed_pass, pass_salt, verified_at, created_at, updated_at, deleted_at, user_id

func (*Queries) LoginOptionGetActiveLoginOption

func (q *Queries) LoginOptionGetActiveLoginOption(ctx context.Context, arg LoginOptionGetActiveLoginOptionParams) (LoginOption, error)

LoginOptionGetActiveLoginOption

SELECT id, login_method, access_key, hashed_pass, pass_salt, verified_at, created_at, updated_at, deleted_at, user_id
FROM login_option
WHERE login_method = $1
    AND access_key = $2
    AND verified_at IS NOT NULL
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) LoginOptionGetActiveLoginOptionWithUser

LoginOptionGetActiveLoginOptionWithUser

SELECT lo.id as login_option_id,
    lo.login_method as login_option_login_method,
    lo.access_key as login_option_access_key,
    lo.hashed_pass as login_option_hashed_pass,
    lo.pass_salt as login_option_pass_salt,
    lo.verified_at as login_option_verified_at,
    lo.created_at as login_option_created_at,
    lo.updated_at as login_option_updated_at,
    lo.deleted_at as login_option_deleted_at,
    u.id as user_id,
    u.username as user_username,
    u.profile_image as user_profile_image,
    u.first_name as user_first_name,
    u.middle_name as user_middle_name,
    u.last_name as user_last_name,
    u.created_at as user_created_at,
    u.updated_at as user_updated_at,
    u.blocked_at as user_blocked_at,
    u.deleted_at as user_deleted_at,
    u.role_id as user_role_id
FROM login_option AS lo
    JOIN users AS u ON lo.user_id = u.id
WHERE lo.login_method = $1
    AND lo.access_key = $2
    AND lo.verified_at IS NOT NULL
    AND lo.deleted_at IS NULL
    AND u.deleted_at IS NULL
LIMIT 1

func (*Queries) LoginOptionGetAllActiveByUserId

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

LoginOptionGetAllActiveByUserId

SELECT id, login_method, access_key, hashed_pass, pass_salt, verified_at, created_at, updated_at, deleted_at, user_id
FROM login_option
WHERE user_id = $1
    AND verified_at IS NOT NULL
    AND deleted_at IS NULL

func (*Queries) LoginOptionGetAllActiveByUserIdAndLoginMethod

func (q *Queries) LoginOptionGetAllActiveByUserIdAndLoginMethod(ctx context.Context, arg LoginOptionGetAllActiveByUserIdAndLoginMethodParams) ([]LoginOption, error)

LoginOptionGetAllActiveByUserIdAndLoginMethod

SELECT id, login_method, access_key, hashed_pass, pass_salt, verified_at, created_at, updated_at, deleted_at, user_id
FROM login_option
WHERE login_method = $1
    AND user_id = $2
    AND verified_at IS NOT NULL
    AND deleted_at IS NULL

func (*Queries) LoginOptionGetAllActiveByUserIdAndSupportPassword

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

LoginOptionGetAllActiveByUserIdAndSupportPassword

SELECT id, login_method, access_key, hashed_pass, pass_salt, verified_at, created_at, updated_at, deleted_at, user_id
FROM login_option
WHERE user_id = $1
    AND hashed_pass IS NOT NULL
    AND verified_at IS NOT NULL
    AND deleted_at IS NULL

func (*Queries) LoginOptionIsAccessKeyUsed

func (q *Queries) LoginOptionIsAccessKeyUsed(ctx context.Context, accessKey string) (int64, error)

LoginOptionIsAccessKeyUsed

SELECT COUNT(*) FROM login_option
WHERE access_key = $1
    AND deleted_at IS NULL
    AND verified_at IS NULL

func (*Queries) LoginOptionMarkUserLoginOptionAsVerified

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

LoginOptionMarkUserLoginOptionAsVerified

UPDATE login_option
SET verified_at = NOW()
WHERE id = $1

func (*Queries) LoginOptionSoftDeleteUserLoginOption

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

LoginOptionSoftDeleteUserLoginOption

UPDATE login_option
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) OTPCreateNewOtp

func (q *Queries) OTPCreateNewOtp(ctx context.Context, arg OTPCreateNewOtpParams) (Otp, error)

OTPCreateNewOtp

INSERT INTO otp (
        code,
        intent,
        otp_for,
        using_session_id,
        expires_at
    )
VALUES ($1, $2, $3, $4, $5)
RETURNING id, code, hit_count, created_at, updated_at, expires_at, deleted_at, intent, otp_for, using_session_id

func (*Queries) OTPGetActiveOtpByIdPairedWithSessionId

func (q *Queries) OTPGetActiveOtpByIdPairedWithSessionId(ctx context.Context, arg OTPGetActiveOtpByIdPairedWithSessionIdParams) (Otp, error)

OTPGetActiveOtpByIdPairedWithSessionId

SELECT id, code, hit_count, created_at, updated_at, expires_at, deleted_at, intent, otp_for, using_session_id
FROM otp
WHERE id = $1
    AND using_session_id = $2
    AND hit_count < 3
    AND expires_at > NOW()
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) OTPRecordHitForOtp

func (q *Queries) OTPRecordHitForOtp(ctx context.Context, id int32) (Otp, error)

OTPRecordHitForOtp

UPDATE otp
SET hit_count = hit_count + 1
WHERE id = $1
RETURNING id, code, hit_count, created_at, updated_at, expires_at, deleted_at, intent, otp_for, using_session_id

func (*Queries) OTPSoftDeleteOtp

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

OTPSoftDeleteOtp

UPDATE otp
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) PerRollAddPermissionToRole

func (q *Queries) PerRollAddPermissionToRole(ctx context.Context, arg PerRollAddPermissionToRoleParams) error

PerRollAddPermissionToRole

INSERT INTO role_permission(role_id, permission_id)
VALUES($1, $2)

func (*Queries) PerRollCreateNewPermission

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

PerRollCreateNewPermission

INSERT INTO permission(name)
VALUES($1)
RETURNING id, name, created_at, updated_at, deleted_at

func (*Queries) PerRollCreateNewRole

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

PerRollCreateNewRole

INSERT INTO role(name)
VALUES($1)
RETURNING id, name, created_at, updated_at, deleted_at

func (*Queries) PerRollGetAllPermissions

func (q *Queries) PerRollGetAllPermissions(ctx context.Context) ([]PerRollGetAllPermissionsRow, error)

PerRollGetAllPermissions

SELECT id,
    name,
    created_at,
    updated_at
FROM permission

func (*Queries) PerRollGetAllRole

func (q *Queries) PerRollGetAllRole(ctx context.Context) ([]PerRollGetAllRoleRow, error)

PerRollGetAllRole

SELECT id,
    name,
    created_at,
    updated_at
FROM role

func (*Queries) PerRollGetRoleWithItsPermissions

func (q *Queries) PerRollGetRoleWithItsPermissions(ctx context.Context, id int32) ([]PerRollGetRoleWithItsPermissionsRow, error)

PerRollGetRoleWithItsPermissions

SELECT r.id as role_id,
    r.name as role_name,
    p.id as permission_id,
    p.name as permission_name
FROM role AS r
    JOIN role_permission AS rp ON r.id = rp.role_id
    JOIN permission AS p ON p.id = rp.permission_id
WHERE r.id = $1

func (*Queries) PerRollRemovePermissionFromRole

func (q *Queries) PerRollRemovePermissionFromRole(ctx context.Context, arg PerRollRemovePermissionFromRoleParams) error

PerRollRemovePermissionFromRole

DELETE FROM role_permission
WHERE role_id = $1
    AND permission_id = $2

func (*Queries) PerRollSoftDeletePermission

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

PerRollSoftDeletePermission

UPDATE permission
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) PerRollSoftDeleteRole

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

PerRollSoftDeleteRole

UPDATE role
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) SessionCreateNewSession

func (q *Queries) SessionCreateNewSession(ctx context.Context, arg SessionCreateNewSessionParams) error

SessionCreateNewSession

INSERT INTO session (
        token,
        originated_from,
        used_installation,
        expires_at
    )
VALUES ($1, $2, $3, $4)

func (*Queries) SessionGetActiveSessionById

func (q *Queries) SessionGetActiveSessionById(ctx context.Context, id int32) (Session, error)

SessionGetActiveSessionById

SELECT id, token, created_at, updated_at, expires_at, deleted_at, originated_from, used_installation
FROM session
WHERE id = $1
    AND expires_at > NOW()
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) SessionGetActiveSessionByToken

func (q *Queries) SessionGetActiveSessionByToken(ctx context.Context, token string) (Session, error)

SessionGetActiveSessionByToken

SELECT id, token, created_at, updated_at, expires_at, deleted_at, originated_from, used_installation
FROM session
WHERE token = $1
    AND expires_at > NOW()
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) SessionSoftDeleteSession

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

SessionSoftDeleteSession

UPDATE session
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) TodoSoftDeleteTodo

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

TodoSoftDeleteTodo

UPDATE todo
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) UsersCreateNewUser

func (q *Queries) UsersCreateNewUser(ctx context.Context, arg UsersCreateNewUserParams) (User, error)

UsersCreateNewUser

INSERT INTO users (
        username,
        profile_image,
        first_name,
        last_name,
        role_id
    )
VALUES ($1, $2, $3, $4, $5)
RETURNING id, username, profile_image, first_name, middle_name, last_name, created_at, updated_at, blocked_at, blocked_until, deleted_at, role_id

func (*Queries) UsersGetUserById

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

UsersGetUserById

SELECT id, username, profile_image, first_name, middle_name, last_name, created_at, updated_at, blocked_at, blocked_until, deleted_at, role_id
FROM users
WHERE id = $1
    AND deleted_at IS NULL
LIMIT 1

func (*Queries) UsersGetUserBySessionToken

func (q *Queries) UsersGetUserBySessionToken(ctx context.Context, token string) (User, error)

UsersGetUserBySessionToken

SELECT u.id, u.username, u.profile_image, u.first_name, u.middle_name, u.last_name, u.created_at, u.updated_at, u.blocked_at, u.blocked_until, u.deleted_at, u.role_id
FROM session AS s
    JOIN login_option AS lo ON s.originated_from = lo.id
    JOIN users AS u ON u.id = lo.user_id
WHERE s.token = $1
    AND s.deleted_at IS NULL
    AND u.deleted_at IS NULL
    AND lo.deleted_at IS NULL
    AND s.expires_at > NOW()
LIMIT 1

func (*Queries) UsersIsUsernameUsed

func (q *Queries) UsersIsUsernameUsed(ctx context.Context, username string) (int64, error)

UsersIsUsernameUsed

SELECT COUNT(*)
FROM users
WHERE username = $1

func (*Queries) UsersSoftDeleteUser

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

UsersSoftDeleteUser

UPDATE users
SET deleted_at = NOW()
WHERE id = $1

func (*Queries) UsersUpdateUserData

func (q *Queries) UsersUpdateUserData(ctx context.Context, arg UsersUpdateUserDataParams) (User, error)

UsersUpdateUserData

UPDATE users
SET username = $2,
    profile_image = $3,
    first_name = $4,
    last_name = $5,
    role_id = $6
WHERE id = $1
RETURNING id, username, profile_image, first_name, middle_name, last_name, created_at, updated_at, blocked_at, blocked_until, deleted_at, role_id

func (*Queries) UsersUpdateUsernameForUser

func (q *Queries) UsersUpdateUsernameForUser(ctx context.Context, arg UsersUpdateUsernameForUserParams) error

UsersUpdateUsernameForUser

UPDATE users
SET username = $2
WHERE id = $1

func (*Queries) WithTx

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

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  *Queries
}

func NewConnection

func NewConnection(ctx context.Context) *Service

func (*Service) Close

func (s *Service) Close()

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"`
	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 SessionCreateNewSessionParams

type SessionCreateNewSessionParams struct {
	Token            string             `json:"token"`
	OriginatedFrom   int32              `json:"originated_from"`
	UsedInstallation int32              `json:"used_installation"`
	ExpiresAt        pgtype.Timestamptz `json:"expires_at"`
}

type Todo

type Todo struct {
	ID        int32              `json:"id"`
	Title     string             `json:"title"`
	Body      pgtype.Text        `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 UsersCreateNewUserParams

type UsersCreateNewUserParams struct {
	Username     string      `json:"username"`
	ProfileImage pgtype.Text `json:"profile_image"`
	FirstName    string      `json:"first_name"`
	LastName     pgtype.Text `json:"last_name"`
	RoleID       pgtype.Int4 `json:"role_id"`
}

type UsersUpdateUserDataParams

type UsersUpdateUserDataParams struct {
	ID           int32       `json:"id"`
	Username     string      `json:"username"`
	ProfileImage pgtype.Text `json:"profile_image"`
	FirstName    string      `json:"first_name"`
	LastName     pgtype.Text `json:"last_name"`
	RoleID       pgtype.Int4 `json:"role_id"`
}

type UsersUpdateUsernameForUserParams

type UsersUpdateUsernameForUserParams struct {
	ID       int32  `json:"id"`
	Username string `json:"username"`
}

Jump to

Keyboard shortcuts

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