mapper

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: LGPL-2.1 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

type Mapper = backends.Mapper

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) DeleteQuery

func (self *Model) DeleteQuery(flt interface{}) error

Delete all records matching the given query.

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) String

func (self *Model) String() string

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 = backends.ResultFunc

Jump to

Keyboard shortcuts

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