Documentation

Index

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

type BookRepo

BookRepo to get book data from database @mock

func NewBookRepo

func NewBookRepo(impl BookRepoImpl) BookRepo

NewBookRepo return new instance of BookRepo @ctor

type BookRepoImpl

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

BookRepoImpl is implementation book repository

func (*BookRepoImpl) Create

func (r *BookRepoImpl) Create(ctx context.Context, book *Book) (int64, error)

Create book

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

Source Files