repository

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 5 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        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

type BookRepository

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

BookRepository to get book data from databasesa

func NewBookRepository

func NewBookRepository(impl BookRepositoryImpl) BookRepository

NewBookRepository return new instance of BookRepository

type BookRepositoryImpl added in v0.6.4

type BookRepositoryImpl struct {
	dig.In
	*sql.DB
}

BookRepositoryImpl is implementation book repository

func (*BookRepositoryImpl) Delete added in v0.6.4

func (r *BookRepositoryImpl) Delete(ctx context.Context, id int64) (err error)

Delete book

func (*BookRepositoryImpl) Find added in v0.6.4

func (r *BookRepositoryImpl) Find(ctx context.Context, id int64) (book *Book, err error)

Find book

func (*BookRepositoryImpl) Insert added in v0.6.4

func (r *BookRepositoryImpl) Insert(ctx context.Context, book Book) (lastInsertID int64, err error)

Insert book

func (*BookRepositoryImpl) List added in v0.6.4

func (r *BookRepositoryImpl) List(ctx context.Context) (list []*Book, err error)

List book

func (*BookRepositoryImpl) Update added in v0.6.4

func (r *BookRepositoryImpl) Update(ctx context.Context, book Book) (err error)

Update book

Jump to

Keyboard shortcuts

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