Documentation ¶
Index ¶
- Constants
- Variables
- type Book
- type Repository
- type SqliteRepository
- func (r *SqliteRepository) Close() error
- func (r *SqliteRepository) DeleteById(id int64) error
- func (r *SqliteRepository) FindAll(includeGenres bool) ([]*Book, error)
- func (r *SqliteRepository) FindById(id int64, includeGenres bool) (*Book, error)
- func (r *SqliteRepository) InsertOne(title string, published int, pages int, rating float64, genres []string) (*Book, error)
- func (r *SqliteRepository) LoadGenres(book *Book) ([]string, error)
- func (r *SqliteRepository) Migrate() error
- func (r *SqliteRepository) Ping() error
- func (r *SqliteRepository) Update(book *Book) error
Constants ¶
View Source
const ( SqliteInsertBookCommand = "INSERT INTO Books (title, published, pages, rating) VALUES (?, ?, ?, ?) RETURNING id, created_at, version" SqliteInsertGenreCommand = "INSERT INTO Genres (book_id, genre_name) VALUES (?, ?) RETURNING id" SqliteSelectBookQuery = "SELECT id, created_at, title, published, pages, rating, version FROM Books WHERE id = ?" SqliteSelectAllBooksQuery = "SELECT id, created_at, title, published, pages, rating, version FROM Books ORDER BY id" SqliteSelectGenresByBookIdCommand = "SELECT genre_name FROM Genres Where book_id = ?" SqliteUpdateBookCommand = `` /* 139-byte string literal not displayed */ SqliteDeleteBookCommand = "DELETE FROM Books WHERE id = ?" )
Variables ¶
View Source
var (
NotFoundError = errors.New("error")
)
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { Migrate() error Ping() error InsertOne(title string, published int, pages int, rating float64, genres []string) (*Book, error) FindById(id int64, includeGenres bool) (*Book, error) FindAll(includeGenres bool) ([]*Book, error) LoadGenres(book *Book) ([]string, error) Update(book *Book) error DeleteById(id int64) error Close() error }
func NewSqliteRepository ¶
func NewSqliteRepository(dsn string) (Repository, error)
type SqliteRepository ¶
type SqliteRepository struct {
// contains filtered or unexported fields
}
func (*SqliteRepository) Close ¶
func (r *SqliteRepository) Close() error
func (*SqliteRepository) DeleteById ¶
func (r *SqliteRepository) DeleteById(id int64) error
func (*SqliteRepository) FindAll ¶
func (r *SqliteRepository) FindAll(includeGenres bool) ([]*Book, error)
func (*SqliteRepository) FindById ¶
func (r *SqliteRepository) FindById(id int64, includeGenres bool) (*Book, error)
func (*SqliteRepository) LoadGenres ¶
func (r *SqliteRepository) LoadGenres(book *Book) ([]string, error)
func (*SqliteRepository) Migrate ¶
func (r *SqliteRepository) Migrate() error
func (*SqliteRepository) Ping ¶
func (r *SqliteRepository) Ping() error
func (*SqliteRepository) Update ¶
func (r *SqliteRepository) Update(book *Book) error
Click to show internal directories.
Click to hide internal directories.