Documentation ¶
Index ¶
- Variables
- type Book
- type BookRepo
- type BookRepoImpl
- func (r *BookRepoImpl) Create(ctx context.Context, book *Book) (int64, error)
- func (r *BookRepoImpl) Delete(ctx context.Context, opt dbkit.DeleteOption) (int64, error)
- func (r *BookRepoImpl) Find(ctx context.Context, opts ...dbkit.SelectOption) (list []*Book, err error)
- func (r *BookRepoImpl) Patch(ctx context.Context, book *Book, opt dbkit.UpdateOption) (int64, error)
- func (r *BookRepoImpl) Update(ctx context.Context, book *Book, opt dbkit.UpdateOption) (int64, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // BookTableName is table name for book entity BookTableName = "books" // BookTable is columns for book entity BookTable = struct { ID string Title string Author string UpdatedAt string CreatedAt string }{ 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 @entity (table:"books" dialect:"postgres")
type BookRepo ¶
type BookRepo interface { Find(context.Context, ...dbkit.SelectOption) ([]*Book, error) Create(context.Context, *Book) (int64, error) Delete(context.Context, dbkit.DeleteOption) (int64, error) Update(context.Context, *Book, dbkit.UpdateOption) (int64, error) Patch(context.Context, *Book, dbkit.UpdateOption) (int64, error) }
BookRepo to get book data from database @mock
func NewBookRepo ¶
func NewBookRepo(impl BookRepoImpl) BookRepo
NewBookRepo return new instance of BookRepo @ctor
type BookRepoImpl ¶
BookRepoImpl is implementation book repository
func (*BookRepoImpl) Delete ¶
func (r *BookRepoImpl) Delete(ctx context.Context, opt dbkit.DeleteOption) (int64, error)
Delete book
func (*BookRepoImpl) Find ¶
func (r *BookRepoImpl) Find(ctx context.Context, opts ...dbkit.SelectOption) (list []*Book, err error)
Find book
func (*BookRepoImpl) Patch ¶
func (r *BookRepoImpl) Patch(ctx context.Context, book *Book, opt dbkit.UpdateOption) (int64, error)
Patch book to update field of book if available
func (*BookRepoImpl) Update ¶
func (r *BookRepoImpl) Update(ctx context.Context, book *Book, opt dbkit.UpdateOption) (int64, error)
Update book
Click to show internal directories.
Click to hide internal directories.