books

package
v0.0.0-...-f3971a3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, db *sql.DB, newBook *models.NewBook) (*models.NewBook, error)

Create adds a new book record to the database.

func DeleteById

func DeleteById(ctx context.Context, db *sql.DB, bookId int) error

DeleteById removes a book record by its ID.

func GetById

func GetById(ctx context.Context, db *sql.DB, bookId int) (*models.Book, error)

GetById retrieves a book by its ID.

func List

func List(ctx context.Context, db *sql.DB) ([]*models.Book, error)

List retrieves all books from the database.

func Update

func Update(ctx context.Context, db *sql.DB, book *models.UpdatedBook) (*models.UpdatedBook, error)

Update modifies an existing book record.

Types

type ErrBookNotFound

type ErrBookNotFound struct {
	Id int
}

ErrBookNotFound represents an error when a book is not found in the database.

func (ErrBookNotFound) Error

func (e ErrBookNotFound) Error() string

type ErrDuplicateBook

type ErrDuplicateBook struct {
	Title  string
	Author string
}

ErrDuplicateBook represents an error when a book with the same title and author already exists.

func (ErrDuplicateBook) Error

func (e ErrDuplicateBook) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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