join

package
v0.0.0-...-49e5460 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoReadJoin

func DoReadJoin(ctx context.Context, client *datamanclient.Client, q *query.Query, joinCollection *Collection, record record.Record) error

TODO: reimplement to do records at once -- so we can batch?

func DoReadJoins

func DoReadJoins(ctx context.Context, client *datamanclient.Client, q *query.Query, meta *metadata.Meta, collection *metadata.Collection, joinField interface{}, records []record.Record) error

TODO: change this to have a flag on whether to stop on error or continue (or maybe switch to channels for the error? then we can decide either way

func NormalizeJoinMap

func NormalizeJoinMap(n string, m JoinMap)

func SortJoinFieldList

func SortJoinFieldList(l []string)

func SplitJoinFieldsString

func SplitJoinFieldsString(collectionName string, joinMap JoinMap) ([]string, []string)

Responsible for splitting and normalizing, not sorting

Types

type Collection

type Collection struct {
	// A pointer to us-- so we can do things like find fields etc.
	M    MetaCollection `json:"-"`
	Name string         `json:"name"`

	ForwardJoin []*ForwardJoin `json:"forward_join,omitempty"`
	// There can be N reverse ones
	ReverseJoin []*ReverseJoin `json:"reverse_join,omitempty"`
}

Represent a collection in the join state

func NewCollection

func NewCollection(m MetaCollection) *Collection

func OrderJoins

func OrderJoins(collectionMetaGetter CollectionGetter, collection MetaCollection, joinMap JoinMap) (*Collection, error)

Return a list of join steps. These can be run in chains

func (*Collection) HasJoins

func (c *Collection) HasJoins() bool

type CollectionGetter

type CollectionGetter func(name string) (MetaCollection, error)

type ForwardJoin

type ForwardJoin struct {
	Key       string                    `json:"key"`
	C         *Collection               `json:"c"`
	JoinField *metadata.CollectionField `json:"join_field"`
	Filter    map[string]interface{}    `json:"filter"`
}

type JoinMap

type JoinMap map[string]map[string]interface{}

TODO: map[string]Filter

func ParseJoinMap

func ParseJoinMap(joinField interface{}) (JoinMap, error)

type MetaCollection

type MetaCollection interface {
	GetName() string
	GetFieldByName(name string) *metadata.CollectionField
	GetField(nameParts []string) *metadata.CollectionField
}

Since router and storage_node have different collections we need an interface which is common)

type ReverseJoin

type ReverseJoin struct {
	Key       string                    `json:"key"`
	C         *Collection               `json:"c"`
	JoinField *metadata.CollectionField `json:"join_field"`
	Filter    map[string]interface{}    `json:"filter"`
}

type WriteJoinSubrecord

type WriteJoinSubrecord struct {
	Path  []string
	Value interface{}
}

Struct to encapsulate returns of writes from subrecords done

func DoWriteJoin

func DoWriteJoin(ctx context.Context, client *datamanclient.Client, q *query.Query, joinCollection *Collection, record record.Record) ([]*WriteJoinSubrecord, error, error)

func DoWriteJoins

func DoWriteJoins(ctx context.Context, client *datamanclient.Client, q *query.Query, meta *metadata.Meta, collection *metadata.Collection, joinField interface{}, record record.Record) ([]*WriteJoinSubrecord, error, error)

TODO: change this to have a flag on whether to stop on error or continue (or maybe switch to channels for the error? then we can decide either way return map[path]subrecord validationError, error

func (*WriteJoinSubrecord) Apply

func (w *WriteJoinSubrecord) Apply(record record.Record)

Jump to

Keyboard shortcuts

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