mapper

package
v2.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: LGPL-2.1 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

type Mapper interface {
	NewInstance(inits ...dal.InitializerFunc) interface{}
	GetBackend() backends.Backend
	GetCollection() *dal.Collection
	Migrate() error
	Drop() error
	Exists(id interface{}) bool
	Create(from interface{}) error
	Get(id interface{}, into interface{}) error
	Update(from interface{}) error
	CreateOrUpdate(id interface{}, from interface{}) error
	Delete(ids ...interface{}) error
	Find(flt interface{}, into interface{}) error
	FindFunc(flt interface{}, destZeroValue interface{}, resultFn ResultFunc) error
	All(into interface{}) error
	Each(destZeroValue interface{}, resultFn ResultFunc) error
	List(fields []string) (map[string][]interface{}, error)
	ListWithFilter(fields []string, flt interface{}) (map[string][]interface{}, error)
	Sum(field string, flt interface{}) (float64, error)
	Count(flt interface{}) (uint64, error)
	Minimum(field string, flt interface{}) (float64, error)
	Maximum(field string, flt interface{}) (float64, error)
	Average(field string, flt interface{}) (float64, error)
	GroupBy(fields []string, aggregates []filter.Aggregate, flt interface{}) (*dal.RecordSet, error)
}

type Model

type Model struct {
	Mapper
	// contains filtered or unexported fields
}

func NewModel

func NewModel(db backends.Backend, collection *dal.Collection) *Model

func (*Model) All

func (self *Model) All(into interface{}) error

func (*Model) Average

func (self *Model) Average(field string, flt interface{}) (float64, error)

func (*Model) Count

func (self *Model) Count(flt interface{}) (uint64, error)

func (*Model) Create

func (self *Model) Create(from interface{}) error

Creates and saves a new instance of the model from the given struct or dal.Record.

func (*Model) CreateOrUpdate

func (self *Model) CreateOrUpdate(id interface{}, from interface{}) error

Creates or updates an instance of the model depending on whether it exists or not.

func (*Model) Delete

func (self *Model) Delete(ids ...interface{}) error

Delete instances of the model identified by the given IDs

func (*Model) Drop

func (self *Model) Drop() error

func (*Model) Each

func (self *Model) Each(destZeroValue interface{}, resultFn ResultFunc) error

func (*Model) Exists

func (self *Model) Exists(id interface{}) bool

Tests whether a record exists for the given ID.

func (*Model) Find

func (self *Model) Find(flt interface{}, into interface{}) error

Perform a query for instances of the model that match the given filter.Filter. Results will be returned in the slice or array pointed to by the into parameter, or if into points to a dal.RecordSet, the RecordSet resulting from the query will be returned as-is.

func (*Model) FindFunc

func (self *Model) FindFunc(flt interface{}, destZeroValue interface{}, resultFn ResultFunc) error

Perform a query for instances of the model that match the given filter.Filter. The given callback function will be called once per result.

func (*Model) Get

func (self *Model) Get(id interface{}, into interface{}) error

Retrieves an instance of the model identified by the given ID and populates the value pointed to by the into parameter. Structs and dal.Record instances can be populated.

func (*Model) GetBackend

func (self *Model) GetBackend() backends.Backend

func (*Model) GetCollection

func (self *Model) GetCollection() *dal.Collection

func (*Model) GroupBy

func (self *Model) GroupBy(fields []string, aggregates []filter.Aggregate, flt interface{}) (*dal.RecordSet, error)

func (*Model) List

func (self *Model) List(fields []string) (map[string][]interface{}, error)

func (*Model) ListWithFilter

func (self *Model) ListWithFilter(fields []string, flt interface{}) (map[string][]interface{}, error)

func (*Model) Maximum

func (self *Model) Maximum(field string, flt interface{}) (float64, error)

func (*Model) Migrate

func (self *Model) Migrate() error

func (*Model) Minimum

func (self *Model) Minimum(field string, flt interface{}) (float64, error)

func (*Model) NewInstance

func (self *Model) NewInstance(inits ...dal.InitializerFunc) interface{}

func (*Model) Sum

func (self *Model) Sum(field string, flt interface{}) (float64, error)

func (*Model) Update

func (self *Model) Update(from interface{}) error

Updates and saves an existing instance of the model from the given struct or dal.Record.

type ResultFunc

type ResultFunc func(ptrToInstance interface{}, err error) // {}

Jump to

Keyboard shortcuts

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