Documentation ¶
Index ¶
- Variables
- func Encrypt(plainText string) (encryptedText string)
- func SessionDeleteAll() (err error)
- func UserDeleteAll() (err error)
- type Post
- type Session
- type Thread
- type User
- func (user *User) Create() (err error)
- func (user *User) CreatePost(conv Thread, body string) (post Post, err error)
- func (user *User) CreateSession() (session Session, err error)
- func (user *User) CreateThread(topic string) (conv Thread, err error)
- func (user *User) Delete() (err error)
- func (user *User) Session() (session Session, err error)
- func (user *User) Update() (err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var Db *sql.DB
Functions ¶
Types ¶
type Post ¶
func (*Post) CreatedAtDate ¶
format the CreatedAt date to display nicely on the screen
type Session ¶
type Session struct { Id int Uuid string // 随机生成的唯一Id,会话机制的核心 Email string UserId int CreatedAt time.Time }
func SessionCheck ¶
checks if the user is logged in and has a session, if not err is not nil
func (*Session) DeleteByUUID ¶
delete session from database
type Thread ¶
func ThreadByUUID ¶
get a thread by the UUID
func (*Thread) CreatedAtDate ¶
format the CreateAt date to display nicely on the screen
func (*Thread) NumReplies ¶
get the number of posts in a thread
type User ¶
type User struct { Id int Uuid string Name string Email string Password string CreatedAt time.Time }
func UserByEmail ¶
get a single user given the email
func UserByUUID ¶
get a single user given the UUID
func (*User) CreatePost ¶
create a new post to a thread
func (*User) CreateSession ¶
create a new session for an existing user
func (*User) CreateThread ¶
create a new thread
Click to show internal directories.
Click to hide internal directories.