storage

package
v0.0.0-...-77d68f8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 13 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 Tx

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

Types

type BookQuery

type BookQuery struct {
	*dusk.Book
	AuthorString string      `db:"author_string"`
	TagString    null.String `db:"tag_string"`
}

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) 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() (dusk.Authors, error)

func (*Store) GetAllBooks

func (s *Store) GetAllBooks() (dusk.Books, error)

func (*Store) GetAllBooksFromAuthor

func (s *Store) GetAllBooksFromAuthor(id int64) (dusk.Books, error)

func (*Store) GetAllBooksFromTag

func (s *Store) GetAllBooksFromTag(id int64) (dusk.Books, error)

func (*Store) GetAllTags

func (s *Store) GetAllTags() (dusk.Tags, error)

func (*Store) GetAuthor

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

func (*Store) GetBook

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

func (*Store) GetTag

func (s *Store) GetTag(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) UpdateTag

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

Jump to

Keyboard shortcuts

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