storage

package
v0.0.0-...-e17cb15 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string) (*sqlx.DB, error)

func Tprintf

func Tprintf(tmpl string, data map[string]interface{}) string

func Tx

func Tx(db *sqlx.DB, txFunc func(*sqlx.Tx) (any, error)) (any, error)

Types

type AuthorQueryRow

type AuthorQueryRow struct {
	*RowMetadata
	*dusk.Author
}

type BookQueryRow

type BookQueryRow struct {
	*RowMetadata
	*BookRow
}

type BookRow

type BookRow struct {
	*dusk.Book
	AuthorString string      `db:"author_string"`
	TagString    null.String `db:"tag_string"`
	Isbn10String null.String `db:"isbn10_string"`
	Isbn13String null.String `db:"isbn13_string"`
	FormatString null.String `db:"format_string"`
	SeriesString null.String `db:"series_string"`
}

type RowMetadata

type RowMetadata struct {
	Total int64 `db:"count"`
	RowNo int64 `db:"rowno"`
}

type Store

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

func New

func New(db *sqlx.DB) *Store

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateAuthor

func (s *Store) CreateAuthor(a *dusk.Author) (*dusk.Author, error)

func (*Store) CreateBook

func (s *Store) CreateBook(b *dusk.Book) (*dusk.Book, error)

func (*Store) CreateTag

func (s *Store) CreateTag(t *dusk.Tag) (*dusk.Tag, error)

func (*Store) DeleteAuthor

func (s *Store) DeleteAuthor(id int64) error

Authors with existing books cannot be deleted. This constraint is introduced to prevent authors from being deleted while they are still linked to existing books. This relationship is only one way as books can be deleted, regardless if their authors still exist. It should also be noted that authors with no books will be deleted automatically in DeleteBook().

func (*Store) DeleteBook

func (s *Store) DeleteBook(id int64) error

func (*Store) DeleteBooks

func (s *Store) DeleteBooks(ids []int64) error

func (*Store) DeleteSeries

func (s *Store) DeleteSeries(id int64) error

Series with existing books CAN be deleted. Their deletion will cause the series to be unlinked from all relevant books.

func (*Store) DeleteTag

func (s *Store) DeleteTag(id int64) error

Tags with existing books CAN be deleted. Their deletion will cause the tag to be unlinked from all relevant books. This relationship goes both ways. A tag that has no books will be deleted automatically.

func (*Store) GetAllAuthors

func (s *Store) GetAllAuthors(f *filters.Search) (*page.Page[dusk.Author], error)

func (*Store) GetAllBooks

func (s *Store) GetAllBooks(f *filters.Book) (*page.Page[dusk.Book], error)

func (*Store) GetAllBooksFromAuthor

func (s *Store) GetAllBooksFromAuthor(id int64, f *filters.Book) (*page.Page[dusk.Book], error)

func (*Store) GetAllBooksFromSeries

func (s *Store) GetAllBooksFromSeries(id int64, f *filters.Book) (*page.Page[dusk.Book], error)

func (*Store) GetAllBooksFromTag

func (s *Store) GetAllBooksFromTag(id int64, f *filters.Book) (*page.Page[dusk.Book], error)

func (*Store) GetAllSeries

func (s *Store) GetAllSeries() ([]*dusk.Series, error)

func (*Store) GetAllTags

func (s *Store) GetAllTags(f *filters.Search) (*page.Page[dusk.Tag], error)

func (*Store) GetAuthor

func (s *Store) GetAuthor(id int64) (*dusk.Author, error)

func (*Store) GetAuthorsFromBook

func (s *Store) GetAuthorsFromBook(id int64) ([]dusk.Author, error)

func (*Store) GetBook

func (s *Store) GetBook(id int64) (*dusk.Book, error)

func (*Store) GetSeries

func (s *Store) GetSeries(id int64) (*dusk.Series, error)

func (*Store) GetTag

func (s *Store) GetTag(id int64) (*dusk.Tag, error)

func (*Store) GetTagsFromBook

func (s *Store) GetTagsFromBook(id int64) ([]dusk.Tag, error)

func (*Store) MigrateUp

func (s *Store) MigrateUp(filePath string) error

func (*Store) UpdateAuthor

func (s *Store) UpdateAuthor(id int64, a *dusk.Author) (*dusk.Author, error)

func (*Store) UpdateBook

func (s *Store) UpdateBook(id int64, b *dusk.Book) (*dusk.Book, error)

func (*Store) UpdateSeries

func (s *Store) UpdateSeries(id int64, a *dusk.Series) (*dusk.Series, error)

func (*Store) UpdateSeriesByName

func (s *Store) UpdateSeriesByName(name string, a *dusk.Series) (*dusk.Series, error)

func (*Store) UpdateTag

func (s *Store) UpdateTag(id int64, a *dusk.Tag) (*dusk.Tag, error)

type TagQueryRow

type TagQueryRow struct {
	*RowMetadata
	*dusk.Tag
}

Jump to

Keyboard shortcuts

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