models

package
v0.0.0-...-812bafd Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conn

func Conn() *sql.DB

func Count

func Count(db *sql.DB, query string, args ...any) (int, error)

func DeleteAccessToken

func DeleteAccessToken(token string)

func GenerateAccessToken

func GenerateAccessToken(userId int64) (string, error)

func InsertUser

func InsertUser(user User) (int64, error)

func InsertUserWithDetails

func InsertUserWithDetails(user User) (int64, error)

func IsEmailExists

func IsEmailExists(email string) (bool, error)

func Login

func Login(email string, password string) (int64, error)

func UpdateAccessToken

func UpdateAccessToken(id int64) error

func UpdateUser

func UpdateUser(user User) (int64, error)

func VerifyAccessToken

func VerifyAccessToken(token string) (int64, int64, error)

Types

type AccessToken

type AccessToken struct {
	ID        int64
	UserID    int64
	Token     string
	ExpiredAt time.Time
}

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

Creating a generic type

type User

type User struct {
	ID        int64  `json:"id"`
	GoogleID  string `json:"-"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Password  string `json:"-"`
}

func GetAuthUser

func GetAuthUser(token string) (User, error)

func GetUserByGoogleId

func GetUserByGoogleId(id string) (User, error)

func GetUserById

func GetUserById[T Number](id T) (User, error)

Generic function

Jump to

Keyboard shortcuts

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