repository

package
v0.8.30 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 7 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:"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, int64, *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
	*sql.DB
}

BookRepoImpl is implementation book repository

func (*BookRepoImpl) Create

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

Create book

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

func (*BookRepoImpl) FindOne

func (r *BookRepoImpl) FindOne(ctx context.Context, id int64) (*Book, error)

FindOne book

func (*BookRepoImpl) Update

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

Update book

Jump to

Keyboard shortcuts

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