models

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	ID       string     `json:"id" bson:"_id"`
	Title    string     `json:"title" bson:"title"`
	Author   string     `json:"author" bson:"author"`
	Synopsis string     `json:"synopsis,omitempty" bson:"synopsis,omitempty"`
	Links    *Link      `json:"links,omitempty" bson:"links,omitempty"`
	History  []Checkout `json:"history,omitempty" bson:"history,omitempty"`
}

A Book contains the fields that identify a book and its status.

func NewBook added in v1.10.0

func NewBook() *Book

NewBook returns a Book structure

func (*Book) Validate

func (b *Book) Validate() error

Validate checks a Book for missing required fields. It returns an error when required fields (e.g. author/title) are not provided.

type Books

type Books struct {
	Count int    `json:"totalCount"`
	Items []Book `json:"items"`
}

Books contains all the items (Book) in the library and a total count of those items

type Checkout

type Checkout struct {
	Who    string
	Out    time.Time
	In     time.Time
	Review int
}

Checkout stores the details of when a someone has borrowed/returned a Book, as well as their review. To be deprecated

type Link struct {
	Self         string `json:"self" bson:"self"`
	Reservations string `json:"reservations" bson:"reservations"`
	Reviews      string `json:"reviews" bson:"reviews"`
}

Link stores the details of when a someone has borrowed/returned a Book, as well user reviews.

type Review added in v1.10.0

type Review struct {
	ID          string      `json:"id" bson:"_id"`
	User        User        `json:"user,omitempty" bson:"user,omitempty"`
	Message     string      `json:"message,omitempty" bson:"message,omitempty"`
	BookID      string      `json:"book_id" bson:"book_id"`
	Links       *ReviewLink `json:"links,omitempty" bson:"links,omitempty"`
	LastUpdated time.Time   `json:"last_updated" bson:"last_updated"`
}

A Review contains the fields that identify a review

func NewReview added in v1.10.0

func NewReview(bookID string) *Review

NewReview returns a Review structure based on a bookID

func (Review) Validate added in v1.10.0

func (r Review) Validate() error
type ReviewLink struct {
	Self string `json:"self" bson:"self"`
	Book string `json:"book" bson:"book"`
}

ReviewLink is the relationship between a Book and a Review

type Reviews added in v1.10.0

type Reviews struct {
	Count int      `json:"totalCount"`
	Items []Review `json:"items"`
}

Reviews contains all the items (Review) in the library and a total count of those items

type User added in v1.10.0

type User struct {
	Forenames string `json:"forenames,omitempty" bson:"forenames,omitempty"`
	Surname   string `json:"surname,omitempty" bson:"surname,omitempty"`
}

Jump to

Keyboard shortcuts

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