funclown

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 5 Imported by: 0

README

funclown

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResourceNotFound is kind of errors for missing database resource.
	ErrResourceNotFound = errors.New("resource not found")
)

Functions

This section is empty.

Types

type DBSelector

type DBSelector interface {
	Reader(context.Context) ReadOnly
	Writer(context.Context) WriterTxn
}

DBSelector provides read-only orm and writable orm.

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory provides building Wrapper object.

func NewFactory

func NewFactory(master, slave *gorm.DB, injectors ...InjectorFn) *Factory

NewFactory returns Wrapper with write permission.

func (*Factory) Reader

func (f *Factory) Reader(ctx context.Context) ReadOnly

Reader returns ORM Wrapper without write permission.

func (*Factory) Writer

func (f *Factory) Writer(ctx context.Context) WriterTxn

Writer returns ORM Wrapper with write permission.

type Injector

type Injector struct {
	DB *gorm.DB
}

Injector represents gorm.DB wrapper for injection.

type InjectorFn added in v0.1.1

type InjectorFn func(context.Context, *Injector)

InjectorFn provides filling process in gorm.DB object or injecting process in other object by gorm.DB.

type NewReader

type NewReader interface {
	New(context.Context) ReadOnly
}

NewReader provides interface for new finder interface.

type NewWriter

type NewWriter interface {
	New(context.Context) WriterTxn
}

NewWriter provides interface for new crud interface.

type OptFn

type OptFn func(db *gorm.DB) *gorm.DB

OptFn provides pattern function for database operation.

func ForUpdate

func ForUpdate() OptFn

ForUpdate returns function for orm.DB.Set("gorm:query_option", "for update") operation.

func IgnoreSoftDelete

func IgnoreSoftDelete() OptFn

IgnoreSoftDelete provides unscoped flag. this makes selectable even if soft deleted.

func Limit

func Limit(limit interface{}) OptFn

Limit returns function for orm.DB.Limit operation.

func Offset

func Offset(offset interface{}) OptFn

Offset returns function for orm.DB.Offset operation.

func Order

func Order(value interface{}, reorder ...bool) OptFn

Order returns function for orm.DB.Order operation.

func Where

func Where(placeholder string, arg interface{}, optargs ...interface{}) OptFn

Where returns function for orm.DB.Where operation.

type OptFnCollection

type OptFnCollection []OptFn

OptFnCollection provides operation object for OptFn list.

func (OptFnCollection) Add

func (c OptFnCollection) Add(fns ...OptFn) OptFnCollection

Add returns new OptFn list with given functions.

type ReadOnly

type ReadOnly interface {
	// contains filtered or unexported methods
}

ReadOnly provides read methods only.

type Wrapper

type Wrapper struct {
	// contains filtered or unexported fields
}

Wrapper provides being able to operate orm.DB with functional option pattern.

func (*Wrapper) Begin

func (w *Wrapper) Begin()

Begin provides delegation to gorm.DB.Begin().

func (*Wrapper) Commit

func (w *Wrapper) Commit()

Commit provides delegation to gorm.DB.Commit().

func (*Wrapper) Count added in v0.1.3

func (w *Wrapper) Count(dto tableDTO, opts ...OptFn) (int, error)

Count provides wrapping operation for gorm.DB.Count().

func (*Wrapper) Delete

func (w *Wrapper) Delete(value tableDTO, opts ...OptFn) error

Delete provides wrapping operation for gorm.DB.Delete().

func (*Wrapper) Find

func (w *Wrapper) Find(out tableDTO, opts ...OptFn) error

Find provides wrapping operation for gorm.DB.First().

func (*Wrapper) FindMulti

func (w *Wrapper) FindMulti(outs tableDTOCollection, opts ...OptFn) error

FindMulti provides wrapping operation for gorm.DB.Find().

func (*Wrapper) Rollback

func (w *Wrapper) Rollback()

Rollback provides delegation to gorm.DB.Rollback().

func (*Wrapper) Save

func (w *Wrapper) Save(resource tableDTO, opts ...OptFn) error

Save provides wrapping operation for gorm.DB.Save().

type Writer

type Writer interface {
	// contains filtered or unexported methods
}

Writer provides interface for repository use.

type WriterInTxn

type WriterInTxn interface {
	Commit()
	Rollback()
	// contains filtered or unexported methods
}

WriterInTxn provides interface for database operation in transaction.

type WriterTxn

type WriterTxn interface {
	Begin()
	// contains filtered or unexported methods
}

WriterTxn provides interface for database operation with beginning transaction.

Jump to

Keyboard shortcuts

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