models

package
v0.0.0-...-8b019b1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 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     int    `json:"id"`
	Title  string `json:"title"`
	Author string `json:"author"`
	Year   string `json:"year"`
}

type BookDB

type BookDB interface {
	GetBooks() ([]Book, error)
	GetBook(id int) (*Book, error)
	AddBook(book *Book) (int64, error)
	UpdateBook(book *Book) (int64, error)
	RemoveBook(id int) (int64, error)
}

type BookService

type BookService interface {
	BookDB
}

func NewBookService

func NewBookService(db *sql.DB) BookService

type Error

type Error struct {
	Message string `json:"message"`
}

type Service

type Service struct {
	Book BookService
	// contains filtered or unexported fields
}

func NewService

func NewService(cfgs ...ServiceConfig) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

type ServiceConfig

type ServiceConfig func(*Service) error

func WithBook

func WithBook() ServiceConfig

func WithDB

func WithDB(name, dsn string) ServiceConfig

Jump to

Keyboard shortcuts

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