database

package
v0.0.0-...-6b2d211 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Database *sqlx.DB

Functions

func InitDb

func InitDb()

func InsertUserAndSession

func InsertUserAndSession(ctx context.Context, user User) (*User, *Session, error)

func IsNoRowsError

func IsNoRowsError(err error) bool

Types

type Session

type Session struct {
	ID        int64     `json:"id" db:"id"`
	UserID    int64     `json:"user_id" db:"user_id"`
	ExpiresAt time.Time `json:"expires_at" db:"expires_at"`
}

func InsertSession

func InsertSession(ctx context.Context, tx sqlx.ExecerContext, session Session) (*Session, error)

func SelectSessionByID

func SelectSessionByID(ctx context.Context, id int) (*Session, error)

type User

type User struct {
	ID             int64  `json:"id" db:"id"`
	Email          string `json:"email" db:"email"`
	HashedPassword string `json:"-" db:"hashed_password"`
}

func InsertUser

func InsertUser(ctx context.Context, tx sqlx.ExecerContext, user User) (*User, error)

func SelectUserByEmail

func SelectUserByEmail(ctx context.Context, email string) (*User, error)

func SelectUserByID

func SelectUserByID(ctx context.Context, id int) (*User, error)

Jump to

Keyboard shortcuts

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