db

package
v0.0.0-...-25002b9 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() *sql.DB

func CreateUser

func CreateUser(db *sql.DB, uuid uuid.UUID, username string, email string, createdAt time.Time, numUploads int, isAdmin bool) error

func CreateUserSession

func CreateUserSession(db *sql.DB, uuid uuid.UUID, userUuid uuid.UUID, createdAt time.Time, expiresAt time.Time) error

func CreateVideo

func CreateVideo(db *sql.DB, url, title string, createdAt time.Time) error

func DeleteExpiredSessions

func DeleteExpiredSessions(db *sql.DB) error

func DeleteUserSessionByToken

func DeleteUserSessionByToken(db *sql.DB, token uuid.UUID) error

func DeleteVideo

func DeleteVideo(db *sql.DB, url string) error

func IncrementUploads

func IncrementUploads(db *sql.DB, userID uuid.UUID) (bool, error)

func Migrate

func Migrate()

Types

type User

type User struct {
	UUID       uuid.UUID
	Username   string
	Email      string
	CreatedAt  time.Time
	NumUploads int
	IsAdmin    bool
}

func GetUser

func GetUser(db *sql.DB, username string, email string) (*User, error)

func GetUserBySession

func GetUserBySession(db *sql.DB, sessionID uuid.UUID) (*User, error)

type UserSession

type UserSession struct {
	UUID      uuid.UUID
	UserUUID  uuid.UUID
	CreatedAt time.Time
	ExpiresAt time.Time
}

func GetUserSession

func GetUserSession(db *sql.DB, userUuid uuid.UUID) (*UserSession, error)

func GetUserSessionByToken

func GetUserSessionByToken(db *sql.DB, token uuid.UUID) (*UserSession, error)

type Video

type Video struct {
	URL       string
	Title     string
	CreatedAt time.Time
}

func GetVideo

func GetVideo(db *sql.DB, url, title string) (*Video, error)

func ListVideos

func ListVideos(db *sql.DB) ([]Video, error)

Jump to

Keyboard shortcuts

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