Documentation
¶
Index ¶
- Variables
- type Book
- type BookRepo
- type BookRepoImpl
- func (r *BookRepoImpl) Create(ctx context.Context, new *Book) (book *Book, err error)
- func (r *BookRepoImpl) Delete(ctx context.Context, id int64) (err error)
- func (r *BookRepoImpl) Find(ctx context.Context, opts ...dbkit.FindOption) (list []*Book, err error)
- func (r *BookRepoImpl) FindOne(ctx context.Context, id int64) (book *Book, err error)
- func (r *BookRepoImpl) Update(ctx context.Context, update *Book) (book *Book, err error)
- type Transactional
Constants ¶
This section is empty.
Variables ¶
View Source
var BookColumns = bookColumns{
ID: "id",
Title: "title",
Author: "author",
UpdatedAt: "updated_at",
CreatedAt: "created_at",
}
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:"update_at"`
CreatedAt time.Time `json:"created_at"`
}
Book represented database model
type BookRepo ¶
type BookRepo interface {
FindOne(context.Context, int64) (*Book, error)
Find(context.Context, ...dbkit.FindOption) ([]*Book, error)
Create(context.Context, *Book) (*Book, error)
Delete(context.Context, int64) error
Update(context.Context, *Book) (*Book, error)
}
BookRepo to get book data from database [mock]
func NewBookRepo ¶
func NewBookRepo(impl BookRepoImpl) BookRepo
NewBookRepo return new instance of BookRepo [constructor]
type BookRepoImpl ¶
type BookRepoImpl struct {
dig.In
*typpostgres.DB
}
BookRepoImpl is implementation book repository
func (*BookRepoImpl) Delete ¶
func (r *BookRepoImpl) Delete(ctx context.Context, id int64) (err error)
Delete book
func (*BookRepoImpl) Find ¶
func (r *BookRepoImpl) Find(ctx context.Context, opts ...dbkit.FindOption) (list []*Book, err error)
Find book
type Transactional ¶
Transactional database
Click to show internal directories.
Click to hide internal directories.