models

package
v0.0.0-...-cd0c578 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ImageDir string = "images/cover_images"
View Source
const LargeCover = "L"
View Source
const MediumCover = "M"
View Source
const Missing int64 = -999998
View Source
const SmallCover = "S"
View Source
const Verbose bool = false

Variables

View Source
var (
	Unknown     = Rating{"Not Rated"}
	VeryGood    = Rating{"Very-Good"}
	Excellent   = Rating{"Excellent"}
	Kindle      = Rating{"Kindle"}
	Interesting = Rating{"Interesting"}
	NotGood     = Rating{"Not-Good"}
)

Functions

func CaptureCoverImages

func CaptureCoverImages(books []Book, imageDir string) error

func CreateBooksDatabase

func CreateBooksDatabase(databaseName string) *gorm.DB

func ExtractSurname

func ExtractSurname(fullName string) string

This might need to get more sophisticated

func TransferJsonBooksToDatabase

func TransferJsonBooksToDatabase(jsonFileName string, db *gorm.DB) error

Types

type Author

type Author struct {
	gorm.Model
	FullName string
	Surname  string
	Books    []Book `gorm:"many2many:book_authors;"`
}

type Book

type Book struct {
	gorm.Model
	PubDate                int64
	DateAdded              time.Time
	AuthorFullName         string
	AuthorSurname          string
	MainTitle              string
	SubTitle               string
	Review                 string
	Rating                 string
	AmazonLink             string
	CoverImageUrl          string
	OpenLibraryUrl         string
	IsfdbUrl               string
	OpenLibraryBookIsbns   []OpenLibraryBookIsbn
	OlCoverId              int64 // Used as the base ID for the image (add suffix -M, -S, -L for sizing.)
	OpenLibraryBookAuthors []OpenLibraryBookAuthor
	OlCoverEditionId       string   // Used to pull up an entry based on a cover
	Authors                []Author `gorm:"many2many:book_authors;"`
}
func (b Book) BookPageLink() template.HTML

func (Book) Create

func (b Book) Create(db *gorm.DB) (uint, error)

func (Book) DisplayRating

func (b Book) DisplayRating() string

func (Book) FormatTitle

func (b Book) FormatTitle() string

func (Book) MakeCoverImageFilename

func (b Book) MakeCoverImageFilename(imageDir string, size string) string

func (Book) MakeCoverImageUrl

func (b Book) MakeCoverImageUrl(size string) string

func (Book) MakeLinkedMediumCoverImageTag

func (b Book) MakeLinkedMediumCoverImageTag() template.HTML

func (Book) MakeLinkedSmallCoverImageTag

func (b Book) MakeLinkedSmallCoverImageTag() template.HTML

func (Book) SiteFileName

func (b Book) SiteFileName() string

type BookSearchResult

type BookSearchResult struct {
	Number             int
	FirstYearPublished int
	Title              string
	Author             string
	AmazonId           string
	CoverEditionKey    string
	EditionIds         []string // all editions
	AuthorIds          []string // Can be more than one author
}

func SearchBook

func SearchBook(title string, author string) []BookSearchResult

func (BookSearchResult) Print

func (s BookSearchResult) Print()

type BooksByAuthor

type BooksByAuthor map[string][]Book

func AllBooksFromJson

func AllBooksFromJson(bookFile string) BooksByAuthor

type OpenLibraryBookAuthor

type OpenLibraryBookAuthor struct {
	gorm.Model
	BookId     uint
	OlAuthorId string
}

type OpenLibraryBookIsbn

type OpenLibraryBookIsbn struct {
	gorm.Model
	BookId uint
	Isbn   string
}

type Rating

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

func StringToRating

func StringToRating(s string) (Rating, error)

func (Rating) Display

func (r Rating) Display() string

func (*Rating) Scan

func (r *Rating) Scan(value interface{}) error

func (Rating) String

func (r Rating) String() string

func (Rating) Value

func (r Rating) Value() (driver.Value, error)

For Gorm

Jump to

Keyboard shortcuts

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