Documentation ¶
Index ¶
- type ErrMapper
- type ErrNoTable
- type Info
- type Mapper
- func (m Mapper) EqualFields(tableName string, one, other interface{}, fields ...interface{}) (bool, error)
- func (m Mapper) GetRowData(tableName string, row *ovsdb.Row, result interface{}) error
- func (m Mapper) NewCondition(tableName string, data interface{}, field interface{}, ...) (*ovsdb.Condition, error)
- func (m Mapper) NewEqualityCondition(tableName string, data interface{}, fields ...interface{}) ([]ovsdb.Condition, error)
- func (m *Mapper) NewMonitorRequest(tableName string, data interface{}, fields []interface{}) (*ovsdb.MonitorRequest, error)
- func (m Mapper) NewMutation(tableName string, data interface{}, column string, mutator ovsdb.Mutator, ...) (*ovsdb.Mutation, error)
- func (m Mapper) NewRow(tableName string, data interface{}, fields ...interface{}) (ovsdb.Row, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrMapper ¶
type ErrMapper struct {
// contains filtered or unexported fields
}
ErrMapper describes an error in an Mapper type
type ErrNoTable ¶
type ErrNoTable struct {
// contains filtered or unexported fields
}
ErrNoTable describes a error in the provided table information
func (*ErrNoTable) Error ¶
func (e *ErrNoTable) Error() string
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info is a struct that handles the type map of an object The object must have exported tagged fields with the 'ovs'
func NewInfo ¶
func NewInfo(table *ovsdb.TableSchema, obj interface{}) (*Info, error)
NewInfo creates a MapperInfo structure around an object based on a given table schema
func (*Info) ColumnByPtr ¶
ColumnByPtr returns the column name that corresponds to the field by the field's pointer
func (*Info) FieldByColumn ¶
FieldByColumn returns the field value that corresponds to a column
type Mapper ¶
type Mapper struct {
Schema *ovsdb.DatabaseSchema
}
Mapper offers functions to interact with libovsdb through user-provided native structs. The way to specify what field of the struct goes to what column in the database id through field a field tag. The tag used is "ovsdb" and has the following structure 'ovsdb:"${COLUMN_NAME}"'
where COLUMN_NAME is the name of the column and must match the schema
Example:
type MyObj struct { Name string `ovsdb:"name"` }
func NewMapper ¶
func NewMapper(schema *ovsdb.DatabaseSchema) *Mapper
NewMapper returns a new mapper
func (Mapper) EqualFields ¶
func (m Mapper) EqualFields(tableName string, one, other interface{}, fields ...interface{}) (bool, error)
EqualFields compares two mapped objects. The indexes to use for comparison are, the _uuid, the table indexes and the columns that correspond to the mapped fields pointed to by 'fields'. They must be pointers to fields on the first mapped element (i.e: one)
func (Mapper) GetRowData ¶
GetRowData transforms a Row to a struct based on its tags The result object must be given as pointer to an object with the right tags
func (Mapper) NewCondition ¶
func (m Mapper) NewCondition(tableName string, data interface{}, field interface{}, function ovsdb.ConditionFunction, value interface{}) (*ovsdb.Condition, error)
NewCondition returns a ovsdb.Condition based on the model
func (Mapper) NewEqualityCondition ¶
func (m Mapper) NewEqualityCondition(tableName string, data interface{}, fields ...interface{}) ([]ovsdb.Condition, error)
NewEqualityCondition returns a list of equality conditions that match a given object A list of valid columns that shall be used as a index can be provided. If none are provided, we will try to use object's field that matches the '_uuid' ovsdb tag If it does not exist or is null (""), then we will traverse all of the table indexes and use the first index (list of simultaneously unique columns) for which the provided mapper object has valid data. The order in which they are traversed matches the order defined in the schema. By `valid data` we mean non-default data.
func (*Mapper) NewMonitorRequest ¶ added in v0.6.0
func (m *Mapper) NewMonitorRequest(tableName string, data interface{}, fields []interface{}) (*ovsdb.MonitorRequest, error)
NewMonitorRequest returns a monitor request for the provided tableName If fields is provided, the request will be constrained to the provided columns If no fields are provided, all columns will be used
func (Mapper) NewMutation ¶
func (m Mapper) NewMutation(tableName string, data interface{}, column string, mutator ovsdb.Mutator, value interface{}) (*ovsdb.Mutation, error)
NewMutation creates a RFC7047 mutation object based on an ORM object and the mutation fields (in native format) It takes care of field validation against the column type
func (Mapper) NewRow ¶
func (m Mapper) NewRow(tableName string, data interface{}, fields ...interface{}) (ovsdb.Row, error)
NewRow transforms an orm struct to a map[string] interface{} that can be used as libovsdb.Row By default, default or null values are skipped. This behavior can be modified by specifying a list of fields (pointers to fields in the struct) to be added to the row