models

package
v0.0.0-...-0731e76 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddComment

func AddComment(c *Comment) (err error)

func AddCourse

func AddCourse(c *Course) (err error)

func AddPost

func AddPost(p *Post) (err error)

func AddUser

func AddUser(u *User) (err error)

func HasUser

func HasUser(user string) (has bool)

func SetupEngine

func SetupEngine() *xorm.Engine

SetupEngine sets up an XORM engine according to the database configuration and syncs the schema.

func UpdateUser

func UpdateUser(u *User) (err error)

Types

type Comment

type Comment struct {
	CommentID     int64         `xorm:"pk autoincr"`
	PostID        int64         `xorm:"notnull"`
	PosterID      string        `xorm:"notnull"`
	Poster        *User         `xorm:"-"`
	Text          string        `xorm:"notnull"`
	FormattedText template.HTML `xorm:"-"`
	CreatedUnix   int64         `xorm:"created"`
	Created       string        `xorm:"-"`
	UpdatedUnix   int64         `xorm:"updated"`
}

func (*Comment) LoadCreated

func (c *Comment) LoadCreated() (err error)

func (*Comment) LoadPoster

func (c *Comment) LoadPoster() (err error)

type Course

type Course struct {
	Code        string `xorm:"pk varchar(64)"`
	Name        string `xorm:"notnull text"`
	Visible     bool   `xorm:"notnull"`
	Locked      bool   `xorm:"notnull"`
	PostsCount  int64  `xorm:"-"`
	Posts       []Post `xorm:"-"`
	CreatedUnix int64  `xorm:"created"`
	Created     string `xorm:"-"`
	UpdatedUnix int64  `xorm:"updated"`
}

func GetCourse

func GetCourse(code string) (*Course, error)

func GetCourses

func GetCourses() (courses []Course)

func (*Course) LoadPosts

func (c *Course) LoadPosts() (err error)

func (*Course) LoadPostsCount

func (c *Course) LoadPostsCount() (err error)

type Post

type Post struct {
	PostID        int64     `xorm:"pk autoincr"`
	CourseCode    string    `xorm:"text notnull"`
	PosterID      string    `xorm:"notnull"`
	Poster        *User     `xorm:"-"`
	Locked        bool      `xorm:"notnull"` // Whether the comments are locked.
	Comments      []Comment `xorm:"-"`
	CommentsCount int64     `xorm:"-"`
	Title         string    `xorm:"text notnull"`
	Text          string    `xorm:"text notnull"`
	CreatedUnix   int64     `xorm:"created"`
	Created       string    `xorm:"-"`
	UpdatedUnix   int64     `xorm:"updated"`
}

func GetAllUserPosts

func GetAllUserPosts(user string) (p []Post, err error)

func GetPost

func GetPost(id string) (*Post, error)

func (*Post) LoadComments

func (p *Post) LoadComments() (err error)

type User

type User struct {
	Username    string `xorm:"pk"`
	FullName    string `xorm:"text null"`
	IsAdmin     bool   `xorm:"bool"`
	Iota        int64
	Created     string `xorm:"-"`
	CreatedUnix int64  `xorm:"created"`
}

func GetUser

func GetUser(user string) (*User, error)

Jump to

Keyboard shortcuts

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