model

package
v0.0.0-...-666e6c6 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBookAuthor

func AddBookAuthor(dbx *sqlx.DB, bookID, authorID int) error

AddBookAuthor registers an existing Author as an author of an existing Book.

func CreateAuthor

func CreateAuthor(dbx *sqlx.DB, name, url string) error

CreateAuthor creates an author.

func CreateEpisode

func CreateEpisode(dbx *sqlx.DB, title string, bookID, indexnum int) error

CreateEpisode creates a new episode.

func CreateSection

func CreateSection(dbx *sqlx.DB, content string, episodeID, indexNum int) error

CreateSection creates a new section.

func RemoveBookAuthor

func RemoveBookAuthor(dbx *sqlx.DB, bookID, authorID int) error

RemoveBookAuthor unregisters an Author from the authors of a Book.

Types

type Author

type Author struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	URL       string    `json:"url"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
}

Author is a novelist, which is eligible to be the author of books.

func GetAuthors

func GetAuthors(dbx *sqlx.DB) ([]Author, error)

GetAuthors fetches the latest authors.

type Book

type Book struct {
	ID        int       `json:"id"`
	Title     string    `json:"title"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	Authors   []Author  `json:"authors"`
	Episodes  []Episode `json:"episodes"`
}

Book is a nutritious book.

func GetBook

func GetBook(dbx *sqlx.DB, bookID int, withEpisode bool) (Book, error)

GetBook fetches an book with its authors and optionally with its episodes.

func GetBooks

func GetBooks(dbx *sqlx.DB) ([]Book, error)

GetBooks fetches the latest books with their authors but without their episodes.

type BookEpi

type BookEpi struct {
	Book    Book    `json:"book"`
	Episode Episode `json:"episode"`
}

BookEpi ties an Episode with a Book.

func GetEpisodeWithBook

func GetEpisodeWithBook(dbx *sqlx.DB, episodeID int) (BookEpi, error)

GetEpisodeWithBook fetches (1) an episode with its sections, and (2) the containing book without its episodes.

type Episode

type Episode struct {
	ID        int       `json:"id"`
	Title     string    `json:"title"`
	BookID    int       `db:"book_id" json:"bookID"`
	IndexNum  int       `json:"index"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	Sections  []Section `json:"sections"`
}

Episode is an episode in a book.

func GetEpisodes

func GetEpisodes(dbx *sqlx.DB, bookID int) ([]Episode, error)

GetEpisodes fetches the episodes of a book, without its sections.

type Section

type Section struct {
	ID        int       `json:"id"`
	Content   string    `json:"content"` // a part of the book body.
	EpisodeID int       `db:"episode_id" json:"episodeID"`
	IndexNum  int       `json:"index"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
}

Section is a section in an episode.

type User

type User struct {
	ID       int
	Nickname string
	Password []byte
}

User is an authentication entry for identifying the users of this service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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