Documentation
¶
Index ¶
- type Book
- type BookRepo
- type BookRepoImpl
- func (r *BookRepoImpl) Delete(ctx context.Context, id int64) (err error)
- func (r *BookRepoImpl) Find(ctx context.Context, id int64) (book *Book, err error)
- func (r *BookRepoImpl) Insert(ctx context.Context, book Book) (lastInsertID int64, err error)
- func (r *BookRepoImpl) List(ctx context.Context) (list []*Book, err error)
- func (r *BookRepoImpl) Update(ctx context.Context, book Book) (err error)
- type CachedBookRepoImpl
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
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
type CachedBookRepoImpl ¶ added in v0.8.0
type CachedBookRepoImpl struct {
dig.In
BookRepoImpl
Redis *redis.Client
}
CachedBookRepoImpl is cached implementation of book repository
Click to show internal directories.
Click to hide internal directories.