Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Cluster *libdata.Cluster
var Validate *validator.Validate
Validate todo
Functions ¶
func GetIdsFromRecordList ¶
func GetIdsFromRecordList(records []libdata.ModelInterface) []string
GetIdsFromRecordList will return the uuid from a list of records.
Types ¶
type Collection ¶
type Collection struct { Definition *Definition Env *Env Update func(interface{}, *fieldmask.FieldMask) error Delete func() error NewPool func() *Pool // contains filtered or unexported fields }
Collection contains several objects of a same model.
func (*Collection) GetByUUID ¶
func (c *Collection) GetByUUID(uuid string) interface{}
GetByUUID will return the specified record in the collection, by UUID.
func (*Collection) Init ¶
func (c *Collection) Init(records []libdata.ModelInterface)
Init will initialize the collection with the specified records.
func (*Collection) Slice ¶
func (c *Collection) Slice() []libdata.ModelInterface
Slice will return the records in the collection, as a slice.
type CustomFunc ¶
CustomFunc represent a custom function.
func (*CustomFunc) Title ¶
func (f *CustomFunc) Title() string
type Definition ¶
type Definition struct { Model *libdata.ModelDefinition Tree bool TranslamodelFields []string TranslateModel *Definition CustomFuncsPool []*CustomFunc CustomFuncsCollection []*CustomFunc // contains filtered or unexported fields }
Definition is used to declare the information of a model, so it can generate its code.
var DataModel *Definition
DataModel is a special definition to import data into the service.
func (*Definition) SetNew ¶
func (d *Definition) SetNew(new func() interface{}) error
SetNew is used to set the new function.
func (*Definition) SetStore ¶
func (d *Definition) SetStore(store interface{}) error
SetStore is used to set the store of the model.
type Definitions ¶
type Definitions struct { Repository string // contains filtered or unexported fields }
func (*Definitions) GenProtos ¶
func (defs *Definitions) GenProtos()
GenProtos will generate the protobuf files for the models.
func (*Definitions) GetByID ¶
func (ds *Definitions) GetByID(id string) *Definition
GetByID return the specified definition by its ID.
func (*Definitions) Register ¶
func (ds *Definitions) Register(d *Definition)
Register is used to register a new definition into the service.
func (*Definitions) Slice ¶
func (ds *Definitions) Slice() []*Definition
Slice return the definitions as a slice.
type Env ¶
type Env struct { Context context.Context Transaction *libdata.Transaction }
Env contain the context in which the current transaction is occurring.
type ModelInterface ¶
type ModelInterface interface { Select( context.Context, *libdata.Transaction, []*libdata.Filter, []string, *uint, *string, *string, ) (*Collection, error) Create(context.Context, *libdata.Transaction, []interface{}) (*Collection, error) Delete( context.Context, *libdata.Transaction, []*libdata.Filter, []string, ) (*Collection, error) SetStore(interface{}) error SetNew(func() interface{}) error }
ModelInterface force to define the function relative to Model.
type Pool ¶
type Pool struct { Definition *Definition Env *Env New func() libdata.ModelInterface Scan func(interface{}, *Collection) ([]libdata.ModelInterface, error) CheckExternalForeignKeys func([]libdata.ModelInterface) error Select func( filters []*libdata.Filter, with []string, limit *uint, after *string, orderByArg *string, ) (*Collection, error) Create func(records []libdata.ModelInterface) (*Collection, error) PostCreate func(records *Collection) error Upsert func([]*libdata.Filter, interface{}, bool) (interface{}, bool, error) }
Pool represent a Model within the current environnement, so we can easily make operation on it.