data

package
v0.0.0-...-d75a980 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *sql.DB

Functions

func Encrypt

func Encrypt(plaintext string) (cryptext string)

hash plaintext with SHA-1

func SessionDeleteAll

func SessionDeleteAll() (err error)

Delete all sessions from database

func UserDeleteAll

func UserDeleteAll() (err error)

Delete all users from database

Types

type Session

type Session struct {
	Id        int
	Uuid      string
	Email     string
	UserId    int
	CreatedAt time.Time
}

func (*Session) Check

func (session *Session) Check() (valid bool, err error)

Check if session is valid in the database

func (*Session) DeleteByUUID

func (session *Session) DeleteByUUID() (err error)

Delete session from database

func (*Session) User

func (session *Session) User() (user User, err error)

Get the user from the session

type Thread

type Thread struct {
	Id        int
	Uuid      string
	Topic     string
	UserId    int
	CreatedAt time.Time
}

func Threads

func Threads() (threads []Thread, err error)

func (*Thread) NumReplies

func (thread *Thread) NumReplies() (count int)

type User

type User struct {
	Id        int
	Uuid      string
	Name      string
	Email     string
	Password  string
	CreatedAt time.Time
}

func UserByEmail

func UserByEmail(email string) (user User, err error)

Get a single user given the email

func UserByUUID

func UserByUUID(uuid string) (user User, err error)

Get a single user given the UUID

func Users

func Users() (users []User, err error)

Get all users in the database and returns it

func (*User) Create

func (user *User) Create() (err error)

Create a new user, save user info into the database

func (*User) CreateSession

func (user *User) CreateSession() (session Session, err error)

Create a new session for an existing user

func (*User) Delete

func (user *User) Delete() (err error)

Delete user from database

func (*User) Session

func (user *User) Session() (session Session, err error)

Get the session for an existing user

func (*User) Update

func (user *User) Update() (err error)

Update user information in the database

Jump to

Keyboard shortcuts

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