repository

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: MIT Imports: 9 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 BookRepo added in v0.8.0

type BookRepo 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
}

BookRepo to get book data from databasesa

func NewBookRepo added in v0.8.0

func NewBookRepo(impl CachedBookRepoImpl) BookRepo

NewBookRepo return new instance of BookRepo

type BookRepoImpl added in v0.8.0

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

BookRepoImpl is implementation book repository

func (*BookRepoImpl) Delete added in v0.8.0

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

Delete book

func (*BookRepoImpl) Find added in v0.8.0

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

Find book

func (*BookRepoImpl) Insert added in v0.8.0

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

Insert book

func (*BookRepoImpl) List added in v0.8.0

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

List book

func (*BookRepoImpl) Update added in v0.8.0

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

Update book

type CachedBookRepoImpl added in v0.8.0

type CachedBookRepoImpl struct {
	dig.In
	BookRepoImpl
	Redis *redis.Client
}

CachedBookRepoImpl is cached implementation of book repository

func (*CachedBookRepoImpl) Find added in v0.8.0

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

Find book entity

func (*CachedBookRepoImpl) List added in v0.8.0

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

List of book entity

Jump to

Keyboard shortcuts

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