Documentation ¶
Index ¶
- type ErrColumnNotFound
- type ErrMapper
- type Info
- type Mapper
- func (m Mapper) EqualFields(one, other *Info, fields ...interface{}) (bool, error)
- func (m Mapper) GetRowData(row *ovsdb.Row, result *Info) error
- func (m Mapper) NewCondition(data *Info, field interface{}, function ovsdb.ConditionFunction, ...) (*ovsdb.Condition, error)
- func (m Mapper) NewEqualityCondition(data *Info, fields ...interface{}) ([]ovsdb.Condition, error)
- func (m Mapper) NewMutation(data *Info, column string, mutator ovsdb.Mutator, value interface{}) (*ovsdb.Mutation, error)
- func (m Mapper) NewRow(data *Info, fields ...interface{}) (ovsdb.Row, error)
- type Metadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrColumnNotFound ¶
type ErrColumnNotFound struct {
// contains filtered or unexported fields
}
ErrColumnNotFound is an error that can occur when the column does not exist for a table
func NewErrColumnNotFound ¶
func NewErrColumnNotFound(column, table string) *ErrColumnNotFound
func (*ErrColumnNotFound) Error ¶
func (e *ErrColumnNotFound) Error() string
Error implements the error interface
type ErrMapper ¶
type ErrMapper struct {
// contains filtered or unexported fields
}
ErrMapper describes an error in an Mapper type
type Info ¶
type Info struct { // FieldName indexed by column Obj interface{} Metadata Metadata }
Info is a struct that wraps an object with its metadata
func NewInfo ¶
func NewInfo(tableName string, 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 (Mapper) EqualFields ¶
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(data *Info, field interface{}, function ovsdb.ConditionFunction, value interface{}) (*ovsdb.Condition, error)
NewCondition returns a ovsdb.Condition based on the model
func (Mapper) NewEqualityCondition ¶
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) NewMutation ¶
func (m Mapper) NewMutation(data *Info, 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