repository

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BookColumns = []string{idColumn, bookTitleColumn, bookAuthorColumn, updatedAtColumn, createdAtColumn}
)

Table Columns

Functions

This section is empty.

Types

type Book

type Book struct {
	ID        int64     `json:"id"`
	Title     string    `json:"title" validate:"required"`
	Author    string    `json:"author" validate:"required"`
	UpdatedAt time.Time `json:"-"`
	CreatedAt time.Time `json:"-"`
}

Book represented database model

func (*Book) Validate

func (b *Book) Validate() error

Validate book

type BookRepository

type BookRepository interface {
	Find(id int64) (*Book, error)
	List() ([]*Book, error)
	Insert(book Book) (lastInsertID int64, err error)
	Delete(id int64) error
	Update(book Book) error
}

BookRepository to get book data from databasesa

func NewBookRepository

func NewBookRepository(conn *sql.DB) BookRepository

NewBookRepository return new instance of BookRepository

Jump to

Keyboard shortcuts

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