db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDatabase

func ConnectToDatabase(driverName string, dsn string) (*bun.DB, error)

func DB

func DB() *bun.DB

func DeleteUser

func DeleteUser(username string) error

func Init

func Init(driverName string, dsn string, debug bool) error

func RunInTx

func RunInTx(fn func(ctx context.Context, tx bun.Tx) error) error

Types

type User

type User struct {
	bun.BaseModel `bun:"table:mtop_user"`

	Username string `bun:"username,notnull,pk" json:"username"`
	Salt     string `bun:"salt,notnull" json:"-"`
	Password string `bun:"password,notnull" json:"password"`

	CreatedTime time.Time `bun:"created_time,notnull,default:current_timestamp" json:"created_time"`
	UpdatedTime time.Time `bun:"updated_time,notnull,default:current_timestamp" json:"updated_time"`
}

func CreateUser

func CreateUser(username, password, salt string) (*User, error)

func GetUserByUsername

func GetUserByUsername(username string) (*User, error)

* return nil if user not found.

func (*User) Auth

func (u *User) Auth(plain string) bool

Jump to

Keyboard shortcuts

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