database

package
v0.0.0-...-23cd6c9 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BOOL

type BOOL int64

func DB_FALSE

func DB_FALSE() BOOL

func DB_TRUE

func DB_TRUE() BOOL

func (BOOL) Value

func (b BOOL) Value() int64

type Category

type Category struct {
	ID         int64  `db:"id"`
	Name       string `db:"name"`
	UserID     int64  `db:"user_id"`
	InsertTime int64  `db:"insert_time"`
}

type CompletePost

type CompletePost struct {
	Post       *Post
	History    []PostHistory
	Categories map[int64][]Category
	Tags       map[int64][]Tag
}

type CompletePostHistory

type CompletePostHistory struct {
	Post       *Post
	History    *PostHistory
	Categories []Category
	Tags       []Tag
}

type Config

type Config struct {
	File string `yaml:"file" validate:"required,min=1"`
}

type Database

type Database struct {
	// contains filtered or unexported fields
}

func New

func New(c Config) (*Database, *sqlx.DB, error)

func (*Database) CreatePost

func (database *Database) CreatePost(post post.Post, posted BOOL) error

func (*Database) GetCategoryById

func (database *Database) GetCategoryById(category_id int64) (*Category, error)

func (*Database) GetCategoryByName

func (database *Database) GetCategoryByName(name string) (*Category, error)

func (*Database) GetCompletePost

func (database *Database) GetCompletePost(post *Post) (*CompletePost, error)

func (*Database) GetDraftPosts

func (database *Database) GetDraftPosts() ([]Post, error)

func (*Database) GetLatestPostHistory

func (database *Database) GetLatestPostHistory(post *Post) (*PostHistory, error)

func (*Database) GetPostById

func (database *Database) GetPostById(id int64) (*Post, error)

func (*Database) GetPostByUrlTitle

func (database *Database) GetPostByUrlTitle(url_title string) (*Post, error)

func (*Database) GetPostCategoryById

func (database *Database) GetPostCategoryById(id int64) (*PostCategory, error)

func (*Database) GetPostHistoryById

func (database *Database) GetPostHistoryById(post_history_id int64) (*PostHistory, error)

func (*Database) GetPostHistoryCategories

func (database *Database) GetPostHistoryCategories(post_history *PostHistory) ([]Category, error)

func (*Database) GetPostHistoryTags

func (database *Database) GetPostHistoryTags(post_history *PostHistory) ([]Tag, error)

func (*Database) GetTagById

func (database *Database) GetTagById(tag_id int64) (*Tag, error)

func (*Database) GetTagByName

func (database *Database) GetTagByName(name string) (*Tag, error)

func (*Database) GetUserById

func (database *Database) GetUserById(id int64) (*User, error)

func (*Database) GetUserByUsername

func (database *Database) GetUserByUsername(username string) (*User, error)

type Post

type Post struct {
	ID         int64  `db:"id"`
	UrlTitle   string `db:"url_title"`
	UserID     int64  `db:"user_id"`
	Title      string `db:"title"`
	Posted     int64  `db:"posted"`
	UpdateTime int64  `db:"update_time"`
	InsertTime int64  `db:"insert_time"`
}

type PostCategory

type PostCategory struct {
	ID         int64 `db:"id"`
	PostID     int64 `db:"post_history_id"`
	CategoryID int64 `db:"category_id"`
	InsertTime int64 `db:"insert_time"`
}

type PostHistory

type PostHistory struct {
	ID         int64  `db:"id"`
	PostID     int64  `db:"post_id"`
	Body       string `db:"body"`
	Method     string `db:"method"`
	InsertTime int64  `db:"insert_time"`
}

type PostTag

type PostTag struct {
	ID         int64 `db:"id"`
	PostID     int64 `db:"post_history_id"`
	TagID      int64 `db:"tag_id"`
	InsertTime int64 `db:"insert_time"`
}

type Tag

type Tag struct {
	ID         int64  `db:"id"`
	Name       string `db:"name"`
	UserID     int64  `db:"user_id"`
	InsertTime int64  `db:"insert_time"`
}

type User

type User struct {
	ID         int64  `db:"id"`
	Username   string `db:"user_name"`
	Firstname  string `db:"first_name"`
	Lastname   string `db:"last_name"`
	UpdateTime int64  `db:"update_time"`
	InsertTime int64  `db:"insert_time"`
}

Jump to

Keyboard shortcuts

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