db

package
v0.0.0-...-24757ee Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateAccountParams

type CreateAccountParams struct {
	Name           string
	Email          string
	HashedPassword string
}

type CreateProfileParams

type CreateProfileParams struct {
	UserID      uuid.UUID
	DisplayName sql.NullString
	Description sql.NullString
	AvatarUrl   sql.NullString
}

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 FollowProfileParams

type FollowProfileParams struct {
	Follower uuid.UUID
	Followed uuid.UUID
}

type GetProfileRow

type GetProfileRow struct {
	ID             uuid.UUID
	UserID         uuid.UUID
	UpdatedAt      sql.NullTime
	DisplayName    sql.NullString
	AvatarUrl      sql.NullString
	Description    sql.NullString
	Links          []string
	ID_2           uuid.UUID
	CreatedAt      time.Time
	UpdatedAt_2    sql.NullTime
	LastLoggedIn   time.Time
	Name           string
	Email          string
	HashedPassword string
	Privilege      UsersPrivileges
}

type NullUsersPrivileges

type NullUsersPrivileges struct {
	UsersPrivileges UsersPrivileges
	Valid           bool // Valid is true if UsersPrivileges is not NULL
}

func (*NullUsersPrivileges) Scan

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

Scan implements the Scanner interface.

func (NullUsersPrivileges) Value

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

Value implements the driver Valuer interface.

type Querier

type Querier interface {
	//------ Accounts --------
	CreateAccount(ctx context.Context, arg *CreateAccountParams) (*UsersAccount, error)
	//------ Profiles --------
	CreateProfile(ctx context.Context, arg *CreateProfileParams) (*UsersProfile, error)
	DeleteAccount(ctx context.Context, id uuid.UUID) error
	DeleteProfile(ctx context.Context, id uuid.UUID) error
	FollowProfile(ctx context.Context, arg *FollowProfileParams) (*UsersFollow, error)
	GetAccount(ctx context.Context, id uuid.UUID) (*UsersAccount, error)
	GetAccountByEmail(ctx context.Context, email string) (*UsersAccount, error)
	GetAccountByName(ctx context.Context, name string) (*UsersAccount, error)
	GetFollowedProfiles(ctx context.Context, follower uuid.UUID) ([]*UsersFollow, error)
	GetProfile(ctx context.Context, userID uuid.UUID) (*GetProfileRow, error)
	GetProfileFollows(ctx context.Context, followed uuid.UUID) ([]*UsersFollow, error)
	UnfollowProfile(ctx context.Context, arg *UnfollowProfileParams) error
	UpdateAccount(ctx context.Context, arg *UpdateAccountParams) (*UsersAccount, error)
	UpdateLastLoggedIn(ctx context.Context, id uuid.UUID) error
	UpdateProfile(ctx context.Context, arg *UpdateProfileParams) (*UsersProfile, error)
	UpdateUserPrivileges(ctx context.Context, arg *UpdateUserPrivilegesParams) (*UsersAccount, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateAccount

func (q *Queries) CreateAccount(ctx context.Context, arg *CreateAccountParams) (*UsersAccount, error)

------ Accounts --------

func (*Queries) CreateProfile

func (q *Queries) CreateProfile(ctx context.Context, arg *CreateProfileParams) (*UsersProfile, error)

------ Profiles --------

func (*Queries) DeleteAccount

func (q *Queries) DeleteAccount(ctx context.Context, id uuid.UUID) error

func (*Queries) DeleteProfile

func (q *Queries) DeleteProfile(ctx context.Context, id uuid.UUID) error

func (*Queries) FollowProfile

func (q *Queries) FollowProfile(ctx context.Context, arg *FollowProfileParams) (*UsersFollow, error)

func (*Queries) GetAccount

func (q *Queries) GetAccount(ctx context.Context, id uuid.UUID) (*UsersAccount, error)

func (*Queries) GetAccountByEmail

func (q *Queries) GetAccountByEmail(ctx context.Context, email string) (*UsersAccount, error)

func (*Queries) GetAccountByName

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

func (*Queries) GetFollowedProfiles

func (q *Queries) GetFollowedProfiles(ctx context.Context, follower uuid.UUID) ([]*UsersFollow, error)

func (*Queries) GetProfile

func (q *Queries) GetProfile(ctx context.Context, userID uuid.UUID) (*GetProfileRow, error)

func (*Queries) GetProfileFollows

func (q *Queries) GetProfileFollows(ctx context.Context, followed uuid.UUID) ([]*UsersFollow, error)

func (*Queries) UnfollowProfile

func (q *Queries) UnfollowProfile(ctx context.Context, arg *UnfollowProfileParams) error

func (*Queries) UpdateAccount

func (q *Queries) UpdateAccount(ctx context.Context, arg *UpdateAccountParams) (*UsersAccount, error)

func (*Queries) UpdateLastLoggedIn

func (q *Queries) UpdateLastLoggedIn(ctx context.Context, id uuid.UUID) error

func (*Queries) UpdateProfile

func (q *Queries) UpdateProfile(ctx context.Context, arg *UpdateProfileParams) (*UsersProfile, error)

func (*Queries) UpdateUserPrivileges

func (q *Queries) UpdateUserPrivileges(ctx context.Context, arg *UpdateUserPrivilegesParams) (*UsersAccount, error)

func (*Queries) WithTx

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

type UnfollowProfileParams

type UnfollowProfileParams struct {
	Follower uuid.UUID
	Followed uuid.UUID
}

type UpdateAccountParams

type UpdateAccountParams struct {
	ID             uuid.UUID
	Name           string
	Email          string
	HashedPassword string
}

type UpdateProfileParams

type UpdateProfileParams struct {
	ID          uuid.UUID
	DisplayName sql.NullString
	Description sql.NullString
	AvatarUrl   sql.NullString
	Links       []string
}

type UpdateUserPrivilegesParams

type UpdateUserPrivilegesParams struct {
	ID        uuid.UUID
	Privilege UsersPrivileges
}

type UsersAccount

type UsersAccount struct {
	ID             uuid.UUID
	CreatedAt      time.Time
	UpdatedAt      sql.NullTime
	LastLoggedIn   time.Time
	Name           string
	Email          string
	HashedPassword string
	Privilege      UsersPrivileges
}

type UsersFollow

type UsersFollow struct {
	ID        uuid.UUID
	CreatedAt time.Time
	Follower  uuid.UUID
	Followed  uuid.UUID
}

type UsersPrivileges

type UsersPrivileges string
const (
	UsersPrivilegesUser      UsersPrivileges = "user"
	UsersPrivilegesModerator UsersPrivileges = "moderator"
	UsersPrivilegesAdmin     UsersPrivileges = "admin"
)

func AllUsersPrivilegesValues

func AllUsersPrivilegesValues() []UsersPrivileges

func (*UsersPrivileges) Scan

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

func (UsersPrivileges) Valid

func (e UsersPrivileges) Valid() bool

type UsersProfile

type UsersProfile struct {
	ID          uuid.UUID
	UserID      uuid.UUID
	UpdatedAt   sql.NullTime
	DisplayName sql.NullString
	AvatarUrl   sql.NullString
	Description sql.NullString
	Links       []string
}

Jump to

Keyboard shortcuts

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