postgres

package
v0.0.0-...-04334a3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_NAME     string = "diva"
	DB_HOST     string = "localhost"
	DB_PORT     uint16 = 5432
	DB_USERNAME string = "diva_user"
	DB_PASSWORD string = "secret_password"
	DB_SCHEMA   string = "public"
)
View Source
const (
	DB_HOST_KEY     string = "DB_HOST"
	DB_PORT_KEY     string = "DB_PORT"
	DB_USER_KEY     string = "DB_USER"
	DB_PASSWORD_KEY string = "DB_PASSWORD"
	DB_NAME_KEY     string = "DB_NAME"
	DB_SCHEMA_KEY   string = "DB_SCHEMA"
	DB_OPTIONS_KEY  string = "DB_OPTIONS"
)

Variables

This section is empty.

Functions

func CreateDeviceParamsFromStorage

func CreateDeviceParamsFromStorage(src *storage.CreateDeviceParams) *pg.CreateDeviceParams

func CreateSessionParamsFromStorage

func CreateSessionParamsFromStorage(src *storage.CreateSessionParams) *pg.CreateSessionParams

func CreateUserParamsFromStorage

func CreateUserParamsFromStorage(src *storage.CreateUserParams) *pg.CreateUserParams

func CreateUserStateParamsFromStorage

func CreateUserStateParamsFromStorage(src *storage.CreateUserStateParams) *pg.CreateUserStateParams

func DivaActionToStorage

func DivaActionToStorage(src *pg.DivaAction) *storage.DivaAction

func DivaDeviceToStorage

func DivaDeviceToStorage(src *pg.DivaDevice) *storage.DivaDevice

func DivaPermissionToStorage

func DivaPermissionToStorage(src *pg.DivaPermission) *storage.DivaPermission

func DivaSessionToStorage

func DivaSessionToStorage(src *pg.DivaSession) *storage.DivaSession

func DivaUserDeviceToStorage

func DivaUserDeviceToStorage(src *pg.DivaUserDevice) *storage.DivaUserDevice

func DivaUserPermissionToStorage

func DivaUserPermissionToStorage(src *pg.DivaUserPermission) *storage.DivaUserPermission

func DivaUserPreferenceToStorage

func DivaUserPreferenceToStorage(src *pg.DivaUserPreference) *storage.DivaUserPreference

func DivaUserProfileToStorage

func DivaUserProfileToStorage(src *pg.DivaUserProfile) *storage.DivaUserProfile

func DivaUserStateToStorage

func DivaUserStateToStorage(src *pg.DivaUserState) *storage.DivaUserState

func DivaUserToStorage

func DivaUserToStorage(src *pg.DivaUser) *storage.DivaUser

func ListPermissionsParamsFromStorage

func ListPermissionsParamsFromStorage(src *storage.ListPermissionsParams) *pg.ListPermissionsParams

func ListUsersParamsFromStorage

func ListUsersParamsFromStorage(src *storage.ListUsersParams) *pg.ListUsersParams

func New

func New(cfg *PGConf) (storage.Storage, error)

func NewPGConf

func NewPGConf() config.Config

func UpdateEmailParamsFromStorage

func UpdateEmailParamsFromStorage(src *storage.UpdateEmailParams) *pg.UpdateEmailParams

func UpdatePasswordParamsFromStorage

func UpdatePasswordParamsFromStorage(src *storage.UpdatePasswordParams) *pg.UpdatePasswordParams

func UpdateRoleParamsFromStorage

func UpdateRoleParamsFromStorage(src *storage.UpdateRoleParams) *pg.UpdateRoleParams

func UpdateSessionParamsFromStorage

func UpdateSessionParamsFromStorage(src *storage.UpdateSessionParams) *pg.UpdateSessionParams

func UpdateUsernameParamsFromStorage

func UpdateUsernameParamsFromStorage(src *storage.UpdateUsernameParams) *pg.UpdateUsernameParams

Types

type DeviceStore

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

func NewDeviceStore

func NewDeviceStore(q *pg.Queries) *DeviceStore

func (*DeviceStore) CreateDevice

func (s *DeviceStore) CreateDevice(ctx context.Context, arg *storage.CreateDeviceParams) error

func (*DeviceStore) CreateUserDevice

func (s *DeviceStore) CreateUserDevice(ctx context.Context, arg *storage.CreateUserDeviceParams) error

func (*DeviceStore) DeleteUserDevice

func (s *DeviceStore) DeleteUserDevice(ctx context.Context, userID uuid.UUID, deviceID uuid.UUID) error

func (*DeviceStore) GetDeviceByID

func (s *DeviceStore) GetDeviceByID(ctx context.Context, id uuid.UUID) (*storage.DivaDevice, error)

func (*DeviceStore) GetDeviceByName

func (s *DeviceStore) GetDeviceByName(ctx context.Context, name string) (*storage.DivaDevice, error)

func (*DeviceStore) GetUserDevice

func (s *DeviceStore) GetUserDevice(ctx context.Context, userID uuid.UUID, deviceID uuid.UUID) (*storage.DivaUserDevice, error)

func (*DeviceStore) ListAllDevices

func (s *DeviceStore) ListAllDevices(ctx context.Context) ([]storage.DivaDevice, error)

func (*DeviceStore) ListUserDevices

func (s *DeviceStore) ListUserDevices(ctx context.Context, userID uuid.UUID) ([]storage.DivaUserDevice, error)

type PGConf

type PGConf struct {
	Name     string `json:"name" validate:"required"`
	Host     string `json:"host" validate:"required"`
	Port     uint16 `json:"port" validate:"required"`
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
	Schema   string `json:"schema"`
	Options  string `json:"options"`
}

func (*PGConf) LoadDefault

func (c *PGConf) LoadDefault()

func (*PGConf) LoadFromEnv

func (c *PGConf) LoadFromEnv()

func (*PGConf) Merge

func (c *PGConf) Merge(config config.Config) error

func (*PGConf) Url

func (c *PGConf) Url() (string, error)

func (*PGConf) Validate

func (c *PGConf) Validate() error

type PGStorage

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

func (*PGStorage) Close

func (s *PGStorage) Close() error

func (*PGStorage) DeviceStore

func (s *PGStorage) DeviceStore() storage.DeviceStore

func (*PGStorage) Health

func (s *PGStorage) Health(ctx context.Context) storage.HealthResult

func (*PGStorage) PermissionStore

func (s *PGStorage) PermissionStore() storage.PermissionStore

func (*PGStorage) SessionStore

func (s *PGStorage) SessionStore() storage.SessionStore

func (*PGStorage) UserActionStore

func (s *PGStorage) UserActionStore() storage.UserActionStore

func (*PGStorage) UserPermissionStore

func (s *PGStorage) UserPermissionStore() storage.UserPermissionStore

func (*PGStorage) UserPreferenceStore

func (s *PGStorage) UserPreferenceStore() storage.UserPreferenceStore

func (*PGStorage) UserProfileStore

func (s *PGStorage) UserProfileStore() storage.UserProfileStore

func (*PGStorage) UserStateStore

func (s *PGStorage) UserStateStore() storage.UserStateStore

func (*PGStorage) UserStore

func (s *PGStorage) UserStore() storage.UserStore

func (*PGStorage) UserVerificationStore

func (s *PGStorage) UserVerificationStore() storage.UserVerificationStore

type PermissionStore

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

func NewPermissionStore

func NewPermissionStore(q *pg.Queries) *PermissionStore

func (*PermissionStore) CountPermissions

func (s *PermissionStore) CountPermissions(ctx context.Context) (int64, error)

func (*PermissionStore) CreatePermission

func (s *PermissionStore) CreatePermission(ctx context.Context, arg *storage.CreatePermissionParams) error

func (*PermissionStore) DeletePermission

func (s *PermissionStore) DeletePermission(ctx context.Context, id uuid.UUID) error

func (*PermissionStore) GetPermissionByID

func (s *PermissionStore) GetPermissionByID(ctx context.Context, id uuid.UUID) (*storage.DivaPermission, error)

func (*PermissionStore) GetPermissionByName

func (s *PermissionStore) GetPermissionByName(ctx context.Context, action string) (*storage.DivaPermission, error)

func (*PermissionStore) ListPermissions

func (*PermissionStore) RestorePermission

func (s *PermissionStore) RestorePermission(ctx context.Context, id uuid.UUID) error

func (*PermissionStore) SoftDeletePermission

func (s *PermissionStore) SoftDeletePermission(ctx context.Context, id uuid.UUID) error

func (*PermissionStore) UpdatePermission

func (s *PermissionStore) UpdatePermission(ctx context.Context, arg *storage.UpdatePermissionParams) error

func (*PermissionStore) UpdatePermissionAction

func (s *PermissionStore) UpdatePermissionAction(ctx context.Context, arg *storage.UpdatePermissionActionParams) error

func (*PermissionStore) UpdatePermissionRoleLevel

func (s *PermissionStore) UpdatePermissionRoleLevel(ctx context.Context, arg *storage.UpdatePermissionRoleLevelParams) error

type SessionStore

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

func NewSessionStore

func NewSessionStore(q *pg.Queries) *SessionStore

func (*SessionStore) CloseAllByUser

func (s *SessionStore) CloseAllByUser(ctx context.Context, userID uuid.UUID) error

func (*SessionStore) CloseExpiredSessions

func (s *SessionStore) CloseExpiredSessions(ctx context.Context) error

func (*SessionStore) CreateSession

func (s *SessionStore) CreateSession(ctx context.Context, arg *storage.CreateSessionParams) error

func (*SessionStore) DeleteSessionsForever

func (s *SessionStore) DeleteSessionsForever(ctx context.Context) error

func (*SessionStore) GetSessionByID

func (s *SessionStore) GetSessionByID(ctx context.Context, id uuid.UUID) (*storage.DivaSession, error)

func (*SessionStore) ListSessions

func (s *SessionStore) ListSessions(ctx context.Context) ([]storage.DivaSession, error)

func (*SessionStore) ListSessionsByUser

func (s *SessionStore) ListSessionsByUser(ctx context.Context, userID uuid.UUID) ([]storage.DivaSession, error)

func (*SessionStore) SoftDeleteSession

func (s *SessionStore) SoftDeleteSession(ctx context.Context, id uuid.UUID) error

func (*SessionStore) UpdateSession

func (s *SessionStore) UpdateSession(ctx context.Context, arg *storage.UpdateSessionParams) error

func (*SessionStore) UpdateSessionStatus

func (s *SessionStore) UpdateSessionStatus(ctx context.Context, arg *storage.UpdateSessionStatusParams) error

type UserActionStore

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

func NewUserActionStore

func NewUserActionStore(q *pg.Queries) *UserActionStore

func (*UserActionStore) CreateUserAction

func (s *UserActionStore) CreateUserAction(ctx context.Context, arg *storage.CreateUserActionParams) error

func (*UserActionStore) DeleteExpiredActions

func (s *UserActionStore) DeleteExpiredActions(ctx context.Context) error

func (*UserActionStore) DeleteUserAction

func (s *UserActionStore) DeleteUserAction(ctx context.Context, id uuid.UUID) error

func (*UserActionStore) DeleteUserActionByUser

func (s *UserActionStore) DeleteUserActionByUser(ctx context.Context, userID uuid.UUID) error

func (*UserActionStore) GetUserActionByID

func (s *UserActionStore) GetUserActionByID(ctx context.Context, id uuid.UUID) (*storage.DivaAction, error)

func (*UserActionStore) GetUserActionByUserAndName

func (s *UserActionStore) GetUserActionByUserAndName(ctx context.Context, arg *storage.GetUserActionByUserAndNameParams) (*storage.DivaAction, error)

func (*UserActionStore) ListActionsByUser

func (s *UserActionStore) ListActionsByUser(ctx context.Context, userID uuid.UUID) ([]storage.DivaAction, error)

type UserPermissionStore

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

func NewUserPermissionStore

func NewUserPermissionStore(q *pg.Queries) *UserPermissionStore

func (*UserPermissionStore) CreateUserPermission

func (s *UserPermissionStore) CreateUserPermission(ctx context.Context, arg *storage.CreateUserPermissionParams) error

func (*UserPermissionStore) DeleteExpiredUserPermissions

func (s *UserPermissionStore) DeleteExpiredUserPermissions(ctx context.Context) error

func (*UserPermissionStore) DeleteUserPermission

func (s *UserPermissionStore) DeleteUserPermission(ctx context.Context, arg *storage.DeleteUserPermissionParams) error

func (*UserPermissionStore) GetUserPermission

func (*UserPermissionStore) GetUserPermissionByName

func (*UserPermissionStore) GetUserPermissions

func (s *UserPermissionStore) GetUserPermissions(ctx context.Context, userID uuid.UUID) ([]storage.DivaUserPermission, error)

func (*UserPermissionStore) UpdateUserPermission

func (s *UserPermissionStore) UpdateUserPermission(ctx context.Context, arg *storage.UpdateUserPermissionParams) error

type UserPreferenceStore

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

func NewUserPreferenceStore

func NewUserPreferenceStore(q *pg.Queries) *UserPreferenceStore

func (*UserPreferenceStore) CreateUserPreferences

func (s *UserPreferenceStore) CreateUserPreferences(ctx context.Context, arg *storage.CreateUserPreferencesParams) error

func (*UserPreferenceStore) GetPreferencesByID

func (s *UserPreferenceStore) GetPreferencesByID(ctx context.Context, id uuid.UUID) (*storage.DivaUserPreference, error)

func (*UserPreferenceStore) GetPreferencesByUser

func (s *UserPreferenceStore) GetPreferencesByUser(ctx context.Context, userID uuid.UUID) ([]storage.DivaUserPreference, error)

func (*UserPreferenceStore) UpdateUserPreferences

func (s *UserPreferenceStore) UpdateUserPreferences(ctx context.Context, arg *storage.UpdateUserPreferencesParams) error

type UserProfileStore

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

func NewUserProfileStore

func NewUserProfileStore(q *pg.Queries) *UserProfileStore

func (*UserProfileStore) CreateUserProfile

func (s *UserProfileStore) CreateUserProfile(ctx context.Context, arg *storage.CreateUserProfileParams) error

func (*UserProfileStore) GetUserProfileByUserID

func (s *UserProfileStore) GetUserProfileByUserID(ctx context.Context, userID uuid.UUID) (*storage.DivaUserProfile, error)

func (*UserProfileStore) UpdateUserProfile

func (s *UserProfileStore) UpdateUserProfile(ctx context.Context, arg *storage.UpdateUserProfileParams) error

func (*UserProfileStore) UpdateUserProfileAvatar

func (s *UserProfileStore) UpdateUserProfileAvatar(ctx context.Context, arg *storage.UpdateUserProfileAvatarParams) error

type UserStateStore

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

func NewUserStateStore

func NewUserStateStore(q *pg.Queries) *UserStateStore

func (*UserStateStore) CreateUserState

func (s *UserStateStore) CreateUserState(ctx context.Context, arg *storage.CreateUserStateParams) error

func (*UserStateStore) GetUserStateByUserID

func (s *UserStateStore) GetUserStateByUserID(ctx context.Context, userID uuid.UUID) (*storage.DivaUserState, error)

func (*UserStateStore) UpdateLastActiveAt

func (s *UserStateStore) UpdateLastActiveAt(ctx context.Context, userID uuid.UUID) error

func (*UserStateStore) UpdateUserStatus

func (s *UserStateStore) UpdateUserStatus(ctx context.Context, arg *storage.UpdateUserStatusParams) error

func (*UserStateStore) UpdateUserVerified

func (s *UserStateStore) UpdateUserVerified(ctx context.Context, arg *storage.UpdateUserVerifiedParams) error

type UserStore

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

func NewUserStore

func NewUserStore(q *pg.Queries) *UserStore

func (*UserStore) CountUsers

func (s *UserStore) CountUsers(ctx context.Context) (int64, error)

func (*UserStore) CreateUser

func (s *UserStore) CreateUser(ctx context.Context, arg *storage.CreateUserParams) error

func (*UserStore) DeleteUser

func (s *UserStore) DeleteUser(ctx context.Context, id uuid.UUID) error

func (*UserStore) GetUserByEmail

func (s *UserStore) GetUserByEmail(ctx context.Context, email string) (*storage.DivaUser, error)

func (*UserStore) GetUserByID

func (s *UserStore) GetUserByID(ctx context.Context, id uuid.UUID) (*storage.DivaUser, error)

func (*UserStore) GetUserByUsername

func (s *UserStore) GetUserByUsername(ctx context.Context, username string) (*storage.DivaUser, error)

func (*UserStore) GetUserByUsernameOrEmail

func (s *UserStore) GetUserByUsernameOrEmail(ctx context.Context, identifier string) (*storage.DivaUser, error)

func (*UserStore) ListUsers

func (s *UserStore) ListUsers(ctx context.Context, arg *storage.ListUsersParams) ([]storage.DivaUser, error)

func (*UserStore) RestoreUser

func (s *UserStore) RestoreUser(ctx context.Context, id uuid.UUID) error

func (*UserStore) SoftDeleteUser

func (s *UserStore) SoftDeleteUser(ctx context.Context, id uuid.UUID) error

func (*UserStore) UpdateEmail

func (s *UserStore) UpdateEmail(ctx context.Context, arg *storage.UpdateEmailParams) error

func (*UserStore) UpdatePassword

func (s *UserStore) UpdatePassword(ctx context.Context, arg *storage.UpdatePasswordParams) error

func (*UserStore) UpdatePhoneNumber

func (s *UserStore) UpdatePhoneNumber(ctx context.Context, arg *storage.UpdatePhoneNumberParams) error

func (*UserStore) UpdateRole

func (s *UserStore) UpdateRole(ctx context.Context, arg *storage.UpdateRoleParams) error

func (*UserStore) UpdateUsername

func (s *UserStore) UpdateUsername(ctx context.Context, arg *storage.UpdateUsernameParams) error

type UserVerificationStore

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

func NewUserVerificationStore

func NewUserVerificationStore(q *pg.Queries) *UserVerificationStore

func (*UserVerificationStore) CreateUserVerification

func (s *UserVerificationStore) CreateUserVerification(ctx context.Context, arg *storage.CreateUserVerificationParams) error

func (*UserVerificationStore) DeleteUserVerification

func (s *UserVerificationStore) DeleteUserVerification(ctx context.Context, actionID uuid.UUID) error

func (*UserVerificationStore) GetUserVerification

func (s *UserVerificationStore) GetUserVerification(ctx context.Context, actionID uuid.UUID) (*storage.DivaActionVerification, error)

func (*UserVerificationStore) UpdateUserVerification

func (s *UserVerificationStore) UpdateUserVerification(ctx context.Context, arg *storage.UpdateUserVerificationParams) error

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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