db

package
v0.0.0-...-aa89e4c Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *sql.DB
)

Functions

func ConnectToDB

func ConnectToDB()

func SignUp

func SignUp(db *sql.DB, UserName, Email, Phone, AvatarUrl string, Role string, PasswordHash string, DateOfBirth string) (int, error)

Insert into users table Postgres does not support LastInsertId. Use Insert and return the ID by selecting it from the database.

func UpdateLastActiveAt

func UpdateLastActiveAt(db *sql.DB, userID int) error

func UpdateUserAvatar

func UpdateUserAvatar(db *sql.DB, id int, avatarUrl string) error

func UpdateUserData

func UpdateUserData(db *sql.DB, userData *UserData) error

func UpdateUserDescription

func UpdateUserDescription(db *sql.DB, id int, description string) error

func UpdateUserEmail

func UpdateUserEmail(db *sql.DB, id int, email string) error

func UpdateUserName

func UpdateUserName(db *sql.DB, id int, userName string) error

func UpdateUserPassword

func UpdateUserPassword(db *sql.DB, id int, passwordHash string) error

func UpdateUserPhone

func UpdateUserPhone(db *sql.DB, id int, phone string) error

func UpdateUserSkills

func UpdateUserSkills(db *sql.DB, id int, skills string) error

func UpdateUserStatus

func UpdateUserStatus(db *sql.DB, id int, status string) error

Types

type Config

type Config struct {
	Data_db Config_db `json:"data_db"`
}

type Config_db

type Config_db struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Username string `json:"username"`
	Password string `json:"password"`
	Dbname   string `json:"dbname"`
}

type Task

type Task struct {
	TaskID          int
	TaskName        string
	TaskDescription string
	SolutionCode    string
	TestCases       interface{}
}

func GetAllTasks

func GetAllTasks() ([]Task, error)

GetAllTasks retrieves all tasks from the database

type UserData

type UserData struct {
	ID                int       `json:"id"`
	UserName          string    `json:"user_name"`
	Description       string    `json:"description"`
	Email             string    `json:"email"`
	Phone             string    `json:"phone"`
	AvatarUrl         string    `json:"avatar_url"`
	Status            string    `json:"status"`
	Role              string    `json:"role"`
	PasswordHash      string    `json:"password_hash"`
	DateOfBirth       time.Time `json:"date_of_birth"`
	PrivacySettings   string    `json:"privacy_settings"`
	IsActive          bool      `json:"is_active"`
	LastLogin         time.Time `json:"last_login"`
	ConfirmationToken string    `json:"confirmation_token"`
	SocialProfiles    string    `json:"social_profiles"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
}

func GetUserData

func GetUserData(db *sql.DB, id int) (*UserData, error)

GetUserData retrieves a user_data record from the database

type UserDataLoginResp

type UserDataLoginResp struct {
	ID                int       `json:"id"`
	UserName          string    `json:"user_name"`
	Description       string    `json:"description"`
	Email             string    `json:"email"`
	Phone             string    `json:"phone"`
	AvatarUrl         string    `json:"avatar_url"`
	Status            string    `json:"status"`
	Role              string    `json:"role"`
	DateOfBirth       time.Time `json:"date_of_birth"`
	PrivacySettings   string    `json:"privacy_settings"`
	IsActive          bool      `json:"is_active"`
	LastLogin         time.Time `json:"last_login"`
	ConfirmationToken string    `json:"confirmation_token"`
	SocialProfiles    string    `json:"social_profiles"`
}

func Login

func Login(db *sql.DB, email, password string) (*UserDataLoginResp, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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