db

package
v0.0.0-...-361d07b Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Id       uint `gorm:"primary_key"`
	Date     int64
	Chatroom string
	Message  string
	User     User
	UserId   uint
}

func GetRecentMessages

func GetRecentMessages(chatroom string, count int) []*Message

func (*Message) Save

func (m *Message) Save()

type Session

type Session struct {
	Id       uint   `gorm:"primary_key"`
	CookieId string `gorm:"unique_index"`
	UserId   uint
	StartTs  uint
}

func GetSession

func GetSession(cookieId string) (*Session, error)

func (*Session) IsLoggedIn

func (s *Session) IsLoggedIn() bool

func (*Session) Login

func (s *Session) Login(username string, password string) (User, error)

func (*Session) Save

func (s *Session) Save() error

func (*Session) Signup

func (s *Session) Signup(username string, password string) (User, error)

type User

type User struct {
	Id           uint   `gorm:"primary_key"`
	Username     string `gorm:"unique_index"`
	PasswordHash string
}

func CreateUser

func CreateUser(username string, hashedPassword string) (User, error)

func GetUser

func GetUser(user User) (User, error)

Jump to

Keyboard shortcuts

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