data

package
v0.0.0-...-86652f6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *sql.DB

Functions

func Check

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

func CreateUUID

func CreateUUID() (uuid string)

CreateUUID create a random UUID with from RFC 4122 adapted from http://github.com/un7hatch/gouuid

func DeleteSession

func DeleteSession(session *utils.Session) (err error)

func Encrypt

func Encrypt(plaintext string) string

Encrypt is f function that hash plaintext with SHA-1

func GetSession

func GetSession(w http.ResponseWriter, r *http.Request) (sess utils.Session, err error)

GetSession function : <br /> Checks if the user is logged in has a session, if not err is not nil

Types

type Post

type Post struct {
	Id        int
	UserId    int
	ThreadId  int
	Uuid      string
	Body      string
	CreatedAt time.Time
}

func (*Post) CreatedAtDate

func (post *Post) CreatedAtDate() string

func (*Post) Save

func (post *Post) Save() (err error)

func (*Post) User

func (post *Post) User() (user User)

User Get the user who wrote the post

type Thread

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

func CreateThread

func CreateThread(user *User, topic string) (conv Thread, err error)

func ThreadByUUID

func ThreadByUUID(uuid string) (conv Thread, err error)

ThreadByUUID Get a thread by the UUID

func Threads

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

func (*Thread) CreatedAtDate

func (thread *Thread) CreatedAtDate() string

CreatedAtDate is method that format the CreatedAt date to display nicely on the screen

func (*Thread) NumReplies

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

func (*Thread) Posts

func (thread *Thread) Posts() (posts []Post, err error)

func (*Thread) User

func (thread *Thread) User() (user User)

User Get the user who started this thread

type User

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

func GetUserBySession

func GetUserBySession(session *utils.Session) (user User, err error)

GetUserBySession method is get a user from session

func UserByEmail

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

Get a single user given the email

func (*User) Create

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

func (*User) CreatePost

func (user *User) CreatePost(conv Thread, body string) (post Post, err error)

func (*User) CreateSession

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

CreateSession create a new session for an existing user

func (*User) CreateThread

func (user *User) CreateThread(topic string) (conv Thread, err error)

CreateThread is a method that to create a new thread

Jump to

Keyboard shortcuts

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