db

package
v0.0.0-...-600b1a9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UniqueViolation = "23505"
)

Variables

View Source
var ErrRecordNotFound = pgx.ErrNoRows

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type CreateUserParams

type CreateUserParams struct {
	Username       string `json:"username"`
	Email          string `json:"email"`
	HashedPassword string `json:"hashed_password"`
	FullName       string `json:"full_name"`
}

type CreateVideoParams

type CreateVideoParams struct {
	Title        string      `json:"title"`
	StreamUrl    string      `json:"stream_url"`
	Description  pgtype.Text `json:"description"`
	ThumbnailUrl pgtype.Text `json:"thumbnail_url"`
	CreatedBy    int64       `json:"created_by"`
}

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 Follow

type Follow struct {
	FollowingUserID int64     `json:"following_user_id"`
	FollowedUserID  int64     `json:"followed_user_id"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type FollowUserParams

type FollowUserParams struct {
	FollowedUserID  int64 `json:"followed_user_id"`
	FollowingUserID int64 `json:"following_user_id"`
}

type GetListFollowerParams

type GetListFollowerParams struct {
	FollowingUserID int64 `json:"following_user_id"`
	Limit           int32 `json:"limit"`
	Offset          int32 `json:"offset"`
}

type GetListFollowingParams

type GetListFollowingParams struct {
	FollowedUserID int64 `json:"followed_user_id"`
	Limit          int32 `json:"limit"`
	Offset         int32 `json:"offset"`
}

type GetListVideoParams

type GetListVideoParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type Querier

type Querier interface {
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	CreateVideo(ctx context.Context, arg CreateVideoParams) (Video, error)
	DeleteVideo(ctx context.Context, id int64) error
	FollowUser(ctx context.Context, arg FollowUserParams) (Follow, error)
	GetListFollower(ctx context.Context, arg GetListFollowerParams) ([]Follow, error)
	GetListFollowing(ctx context.Context, arg GetListFollowingParams) ([]Follow, error)
	GetListVideo(ctx context.Context, arg GetListVideoParams) ([]Video, error)
	GetUser(ctx context.Context, id int64) (User, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	GetVideo(ctx context.Context, id int64) (Video, error)
	UnfollowUser(ctx context.Context, arg UnfollowUserParams) error
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
	UpdateVideo(ctx context.Context, arg UpdateVideoParams) (Video, error)
}

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) CreateVideo

func (q *Queries) CreateVideo(ctx context.Context, arg CreateVideoParams) (Video, error)

func (*Queries) DeleteVideo

func (q *Queries) DeleteVideo(ctx context.Context, id int64) error

func (*Queries) FollowUser

func (q *Queries) FollowUser(ctx context.Context, arg FollowUserParams) (Follow, error)

func (*Queries) GetListFollower

func (q *Queries) GetListFollower(ctx context.Context, arg GetListFollowerParams) ([]Follow, error)

func (*Queries) GetListFollowing

func (q *Queries) GetListFollowing(ctx context.Context, arg GetListFollowingParams) ([]Follow, error)

func (*Queries) GetListVideo

func (q *Queries) GetListVideo(ctx context.Context, arg GetListVideoParams) ([]Video, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) GetVideo

func (q *Queries) GetVideo(ctx context.Context, id int64) (Video, error)

func (*Queries) UnfollowUser

func (q *Queries) UnfollowUser(ctx context.Context, arg UnfollowUserParams) error

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) UpdateVideo

func (q *Queries) UpdateVideo(ctx context.Context, arg UpdateVideoParams) (Video, error)

func (*Queries) WithTx

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

type SQLStore

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

type Store

type Store interface {
	Querier
}

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

NewStore returns a new store

type UnfollowUserParams

type UnfollowUserParams struct {
	FollowedUserID  int64 `json:"followed_user_id"`
	FollowingUserID int64 `json:"following_user_id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	HashedPassword pgtype.Text `json:"hashed_password"`
	Email          pgtype.Text `json:"email"`
	FullName       pgtype.Text `json:"full_name"`
	Username       string      `json:"username"`
}

type UpdateVideoParams

type UpdateVideoParams struct {
	Title        pgtype.Text `json:"title"`
	StreamUrl    pgtype.Text `json:"stream_url"`
	Description  pgtype.Text `json:"description"`
	ThumbnailUrl pgtype.Text `json:"thumbnail_url"`
	ID           int64       `json:"id"`
}

type User

type User struct {
	ID             int64     `json:"id"`
	Username       string    `json:"username"`
	Email          string    `json:"email"`
	HashedPassword string    `json:"hashed_password"`
	FullName       string    `json:"full_name"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type Video

type Video struct {
	ID           int64       `json:"id"`
	Title        string      `json:"title"`
	StreamUrl    string      `json:"stream_url"`
	Description  pgtype.Text `json:"description"`
	ThumbnailUrl pgtype.Text `json:"thumbnail_url"`
	CreatedBy    int64       `json:"created_by"`
	CreatedAt    time.Time   `json:"created_at"`
	UpdatedAt    time.Time   `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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