repo

package
v0.9.22-0...-fc01a12 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BookTableName = "books"
	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     `column:"id" option:"pk" json:"id"`
	Title     string    `column:"title" json:"title"`
	Author    string    `column:"author" json:"author"`
	UpdatedAt time.Time `column:"updated_at" option:"now" json:"update_at"`
	CreatedAt time.Time `column:"created_at" option:"now,no_update" json:"created_at"`
}

type BookRepo

type BookRepo interface {
	Count(context.Context, ...sqkit.SelectOption) (int64, error)
	Find(context.Context, ...sqkit.SelectOption) ([]*Book, error)
	Insert(context.Context, *Book) (int64, error)
	BulkInsert(context.Context, ...*Book) (int64, error)
	Delete(context.Context, ...sqkit.DeleteOption) (int64, error)
	Update(context.Context, *Book, ...sqkit.UpdateOption) (int64, error)
	Patch(context.Context, *Book, ...sqkit.UpdateOption) (int64, error)
}

@mock

func NewBookRepo

func NewBookRepo(impl BookRepoImpl) BookRepo

@ctor

type BookRepoImpl

type BookRepoImpl struct {
	dig.In
	*sql.DB `name:"pg"`
}

func (*BookRepoImpl) BulkInsert

func (r *BookRepoImpl) BulkInsert(ctx context.Context, ents ...*Book) (int64, error)

BulkInsert books and return affected rows

func (*BookRepoImpl) Count

func (r *BookRepoImpl) Count(ctx context.Context, opts ...sqkit.SelectOption) (int64, error)

Count books

func (*BookRepoImpl) Delete

func (r *BookRepoImpl) Delete(ctx context.Context, opts ...sqkit.DeleteOption) (int64, error)

Delete books

func (*BookRepoImpl) Find

func (r *BookRepoImpl) Find(ctx context.Context, opts ...sqkit.SelectOption) (list []*Book, err error)

Find books

func (*BookRepoImpl) Insert

func (r *BookRepoImpl) Insert(ctx context.Context, ent *Book) (int64, error)

Insert books and return last inserted id

func (*BookRepoImpl) Patch

func (r *BookRepoImpl) Patch(ctx context.Context, ent *Book, opts ...sqkit.UpdateOption) (int64, error)

Patch books

func (*BookRepoImpl) Update

func (r *BookRepoImpl) Update(ctx context.Context, ent *Book, opts ...sqkit.UpdateOption) (int64, error)

Update books

Jump to

Keyboard shortcuts

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