mapper

package
v4.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: LGPL-2.1 Imports: 10 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(ctx context.Context, into interface{}) error

func (*Model) Average

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

func (*Model) Count

func (self *Model) Count(ctx context.Context, flt interface{}) (uint64, error)

func (*Model) Create

func (self *Model) Create(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, ids ...interface{}) error

Delete instances of the model identified by the given IDs

func (*Model) DeleteQuery

func (self *Model) DeleteQuery(ctx context.Context, flt interface{}) error

Delete all records matching the given query.

func (*Model) Drop

func (self *Model) Drop(ctx context.Context) error

func (*Model) Each

func (self *Model) Each(ctx context.Context, destZeroValue interface{}, resultFn ResultFunc) error

func (*Model) Exists

func (self *Model) Exists(ctx context.Context, id interface{}) bool

Tests whether a record exists for the given ID.

func (*Model) Find

func (self *Model) Find(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, fields []string, aggregates []filter.Aggregate, flt interface{}) (*dal.RecordSet, error)

func (*Model) List

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

func (*Model) ListWithFilter

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

func (*Model) Maximum

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

func (*Model) Migrate

func (self *Model) Migrate(ctx context.Context) error

func (*Model) Minimum

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

func (*Model) String

func (self *Model) String() string

func (*Model) Sum

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

func (*Model) Update

func (self *Model) Update(ctx context.Context, 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