models

package
v0.0.0-...-5907adb Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 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
}

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)

Jump to

Keyboard shortcuts

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