dao

package module
v0.0.0-...-0da35a1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCursorLimit = 1000
	DefaultPageSize    = 20
)

Variables

View Source
var Daos = []interface{}{new(Dao)}

Functions

func GenerateColumnNames

func GenerateColumnNames(targetFile string, models ...interface{}) error

func IsRecordNotFound

func IsRecordNotFound(err error) bool

Types

type BeforeCreateOrUpdate

type BeforeCreateOrUpdate interface {
	BeforeCreateOrUpdate() map[string]interface{}
}

type ColumnInfo

type ColumnInfo func() (string, interface{})

type Cursor

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

func NewCursor

func NewCursor(limit, offset int) *Cursor

func NewFirstPageCursor

func NewFirstPageCursor() *Cursor

func (*Cursor) Limit

func (c *Cursor) Limit() int

func (*Cursor) NextPage

func (c *Cursor) NextPage() *Cursor

func (*Cursor) Offset

func (c *Cursor) Offset() int

func (*Cursor) Serialize

func (c *Cursor) Serialize() string

func (*Cursor) Unserialize

func (c *Cursor) Unserialize(serialized string) error

type Dao

type Dao struct {
	Logger         Logger
	StatsCollector DbStatsCollector

	Debug bool
	// contains filtered or unexported fields
}

func New

func New(database string, connectionString string, models ...interface{}) (*Dao, error)

func NewDebug

func NewDebug(database string, connectionString string, models ...interface{}) (*Dao, error)

func (*Dao) ByID

func (d *Dao) ByID(c context.Context, m Model, id uuid.UUID) error

func (*Dao) ByStringID

func (d *Dao) ByStringID(c context.Context, m Model, strID string) error

func (*Dao) Clean

func (d *Dao) Clean() error

func (*Dao) Create

func (d *Dao) Create(c context.Context, m Model) error

func (*Dao) CreateOrUpdate

func (d *Dao) CreateOrUpdate(c context.Context, m Model) error

func (*Dao) CreateOrUpdateColumns

func (d *Dao) CreateOrUpdateColumns(c context.Context, m Model, ci ...ColumnInfo) error

func (*Dao) Delete

func (d *Dao) Delete(c context.Context, m Model) error

func (*Dao) DeprecatedUpdateColumn

func (d *Dao) DeprecatedUpdateColumn(c context.Context, model Model, col string, val interface{}) error

func (*Dao) DeprecatedUpdateColumns

func (d *Dao) DeprecatedUpdateColumns(c context.Context, model Model, cols map[string]interface{}) error

func (*Dao) GetDeletedByID

func (d *Dao) GetDeletedByID(c context.Context, m Model, id uuid.UUID) error

func (*Dao) HardDelete

func (d *Dao) HardDelete(c context.Context, m Model) error

func (*Dao) IncrColumn

func (d *Dao) IncrColumn(c context.Context, model Model, col string, incr float64) error

func (*Dao) Init

func (d *Dao) Init() error

func (*Dao) IsRecordNotFound

func (d *Dao) IsRecordNotFound(err error) bool

func (*Dao) Load

func (d *Dao) Load(c context.Context, m Model) error

func (*Dao) Print

func (d *Dao) Print(v ...interface{})

Print is used to log sql statements (implementation of gorm.logger)

func (*Dao) Query

func (d *Dao) Query(c context.Context) *Query

func (*Dao) UpdateColumns

func (d *Dao) UpdateColumns(c context.Context, model Model, ci ...ColumnInfo) error

type DbStatsCollector

type DbStatsCollector interface {
	AddDbStats(c context.Context, since time.Time, queryFmt string, params ...interface{})
}

type DummyDbStatsCollector

type DummyDbStatsCollector struct{}

func (DummyDbStatsCollector) AddDbStats

func (DummyDbStatsCollector) AddDbStats(c context.Context, since time.Time, query string, params ...interface{})

type Logger

type Logger interface {
	Debugf(c context.Context, format string, args ...interface{})
	Infof(c context.Context, format string, args ...interface{})
	Warningf(c context.Context, format string, args ...interface{})
	Errorf(c context.Context, format string, args ...interface{})
	Error(c context.Context, err error, format string, args ...interface{})
	Criticalf(c context.Context, format string, args ...interface{})
}

func NewStdoutLogger

func NewStdoutLogger() Logger

type Model

type Model interface {
	GetID() uuid.UUID
	GenerateID()
	IsIDNil() bool
}

type Query

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

func (*Query) All

func (q *Query) All(target interface{}) error

func (*Query) Count

func (q *Query) Count(sample Model) (int, error)

func (*Query) Filter

func (q *Query) Filter(column, operation string, value interface{}) *Query

func (*Query) FilterExpression

func (q *Query) FilterExpression(expression string, values ...interface{}) *Query

func (*Query) First

func (q *Query) First(target Model) error

func (*Query) IncludeDeleted

func (q *Query) IncludeDeleted() *Query

func (*Query) OrderBy

func (q *Query) OrderBy(column string, ascDesc ...string) *Query

func (*Query) WithDefaultPageSize

func (q *Query) WithDefaultPageSize() *Query

func (*Query) WithPageSize

func (q *Query) WithPageSize(s int) *Query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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