model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FixtureData

type FixtureData map[string]interface{}

type FixtureFields

type FixtureFields map[string]interface{}

type FixtureRecords

type FixtureRecords map[string]FixtureFields

type FixtureTables

type FixtureTables map[string]FixtureRecords

type Iterator

type Iterator func(key string, value *Row)

Iterator is a func that can iterate a tree

type Node

type Node struct {
	Left  *Node
	Right *Node
	Key   string
	Value *Row
}

Node is a Node in a Binary Tree

func NewNode

func NewNode(row *Row) *Node

NewNode Return a new empty node

func (*Node) Add

func (me *Node) Add(node *Node) *Node

Add an existing node to this node's subtree

func (*Node) EqualTo

func (me *Node) EqualTo(other *Node) bool

EqualTo return true if this row is equal to the other.

func (*Node) GreaterThan

func (me *Node) GreaterThan(other *Node) bool

GreaterThan return true if this row has dependancy of other.

func (*Node) HasDependencyOf

func (me *Node) HasDependencyOf(name string) bool

HasDependencyOf is True if the Row have a dependancy with the other row pass

func (*Node) LessThan

func (me *Node) LessThan(other *Node) bool

LessThan return true if this row hasn't dependancy with other.

func (*Node) Maximum

func (me *Node) Maximum() *Node

Maximum Return the right-most (largest key) node in this node's subtree

func (*Node) Minimum

func (me *Node) Minimum() *Node

Minimum Return the left-most (smallest key) node in this node's subtree

func (*Node) WalkBackward

func (me *Node) WalkBackward(iterator func(me *Node))

WalkBackward Call iterator for each node in this node's subtree in reverse order, high to low

func (*Node) WalkForward

func (me *Node) WalkForward(iterator func(me *Node))

WalkForward Call iterator for each node in this node's subtree in order, low to high

type ObjectSet

type ObjectSet struct {
	TableName           string
	HasExtend           bool
	Name                string
	RangeReference      string
	ParentName          string
	Fields              map[string]interface{}
	RangeRowReference   []string
	DependancyReference []string
}

ObjectSet contains metadatas necessary to build row

func NewObjectSet

func NewObjectSet(tableName string, name string, fields map[string]interface{}, hasExtend bool, rangeReference string, parentName string) *ObjectSet

NewObjectSet is a factory to create an ObjectSet

type Relation

type Relation struct {
	RecordName string
	FieldName  string
}

Relation represents a relation to an another record

func NewRelation

func NewRelation(value string) (*Relation, error)

NewRelation create a relation structure

type Row

type Row struct {
	Name                string
	TableName           string
	Fields              map[string]interface{}
	DependencyReference map[string]*Relation
	Left                *Row
	Right               *Row
	Pk                  interface{}
}

Row represente data that will be persist in database

func NewRow

func NewRow(name, tableName string) *Row

NewRow Factory to build a Row Structure

func (*Row) HasDependencies

func (r *Row) HasDependencies() bool

HasDependencies return true if this row has dependancies

func (*Row) HasDependencyOf

func (r *Row) HasDependencyOf(name string) bool

HasDependencyOf is True if the Row have a dependancy with the other row pass

func (Row) PrintDebug

func (r Row) PrintDebug()

PrintDebug is a temporary method to dump a Row

type Template

type Template struct {
	Name   string
	Fields map[string]interface{}
}

Template Container to describe the common fields shared between ObjectSet

func NewTemplate

func NewTemplate(Name string, Fields map[string]interface{}) *Template

NewTemplate is a factory to create a Template structure

type Tree

type Tree struct {
	Records map[string]*Node
	Root    *Node
}

Tree is a binary tree of record It sort record with relation

func NewTree

func NewTree() *Tree

NewTree create an instance of tre

func (*Tree) Add

func (me *Tree) Add(record *Row)

Add a record in the tree

func (*Tree) Find

func (me *Tree) Find(key string) *Node

Find and return the node with the supplied key in this subtree. Return nil if not found.

func (*Tree) First

func (me *Tree) First() (string, *Row)

First Return the first (lowest) key and value in the tree, or nil, nil if the tree is empty.

func (*Tree) Last

func (me *Tree) Last() (string, *Row)

Last Return the last (highest) key and value in the tree, or nil, nil if the tree is empty.

func (*Tree) Walk

func (me *Tree) Walk(iterator Iterator, forward bool)

Walk Iterate the tree with the function in the supplied direction

Jump to

Keyboard shortcuts

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