model

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package model holds structs of the Gremlin counterparts and related methods.

These structs can be used as an unmarshalled version of a graph database's copy on the graph itself. With these structures you can alter their graph counter-part rather than creating manual graph traversals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIData

type APIData struct {
	Label      string            `json:"dbName"`
	Vertex     string            `json:"tableName"`
	Properties map[string]string `json:"cols"`
}

APIData holds the request in which you can make a query with using the Grammes library.

type Data

type Data struct {
	DBName    string    `json:"dbName"`
	TableName string    `json:"tableName"`
	Columns   []DataMap `json:"columns"`
}

Data holds basic information such as the label, name, ID, and properties of what this is being associated with.

type DataMap

type DataMap map[string]interface{}

DataMap is used to store data

type Edge

type Edge struct {
	Type  string    `json:"@type"`
	Value EdgeValue `json:"@value"`
}

Edge is the object that builds a connection between two or more vertices.

Tinkerpop: http://tinkerpop.apache.org/javadocs/3.2.1/core/org/apache/tinkerpop/gremlin/structure/Edge.html

outVertex ---label---> inVertex.

func UnmarshalEdgeList

func UnmarshalEdgeList(data [][]byte) ([]Edge, error)

UnmarshalEdgeList is a utility to unmarshal a list or array of edges properly.

func (*Edge) ID

func (e *Edge) ID() interface{}

ID will retrieve the Edge ID for you.

func (*Edge) InVertexID

func (e *Edge) InVertexID() interface{}

InVertexID will retrieve the id for the vertex that the edge goes into.

func (*Edge) InVertexLabel

func (e *Edge) InVertexLabel() string

InVertexLabel will retrieve the label for the vertex the edge goes into.

func (*Edge) Label

func (e *Edge) Label() string

Label will retrieve the Edge Label for you.

func (*Edge) OutVertexID

func (e *Edge) OutVertexID() interface{}

OutVertexID will retrieve the id for the vertex that the edge goes out of.

func (*Edge) OutVertexLabel

func (e *Edge) OutVertexLabel() string

OutVertexLabel will retrieve the label for the vertex the edge goes out of.

func (*Edge) PropertyValue

func (e *Edge) PropertyValue(key string) interface{}

PropertyValue will retrieve the Property for you.

func (*Edge) QueryInVertex

func (e *Edge) QueryInVertex(client queryClient) (Vertex, error)

QueryInVertex will retrieve the vertex that the edge comes out of.

func (*Edge) QueryOutVertex

func (e *Edge) QueryOutVertex(client queryClient) (Vertex, error)

QueryOutVertex will retrieve the vertex that the edge comes out of.

type EdgeList

type EdgeList struct {
	Edges []Edge
	// contains filtered or unexported fields
}

EdgeList is used for unmarshalling after querying. We use this instead of []Edge for Gremlin v3.0 compatibility.

func (*EdgeList) UnmarshalJSON

func (l *EdgeList) UnmarshalJSON(data []byte) error

UnmarshalJSON overrides to assure a proper unmarshal.

type EdgeProperties

type EdgeProperties map[string]EdgePropertyDetails

EdgeProperties need to be different than Vertex ones because they're not an array/slice. It's only a map of keys and values.

type EdgePropertyDetails

type EdgePropertyDetails struct {
	Type  string            `json:"@type"`
	Value EdgePropertyValue `json:"@value"`
}

EdgePropertyDetails contains the details and meta data about the property itself.

type EdgePropertyValue

type EdgePropertyValue struct {
	Key   string       `json:"key"`
	Value ValueWrapper `json:"value"`
}

EdgePropertyValue will hold the actual value and key for the property.

type EdgeValue

type EdgeValue struct {
	ID         interface{}    `json:"id"`
	Label      string         `json:"label"`
	InVLabel   string         `json:"inVLabel,omitempty"`
	OutVLabel  string         `json:"outVLabel,omitempty"`
	InV        interface{}    `json:"inV,omitempty"`
	OutV       interface{}    `json:"outV,omitempty"`
	Properties EdgeProperties `json:"properties,omitempty"`
}

EdgeValue contains the 'value' data from the Edge object.

type IDList

type IDList struct {
	IDs []interface{}
	// contains filtered or unexported fields
}

IDList is used for unmarshalling after querying. We use this instead of []ID for Gremlin v3.0 compatibility.

func (*IDList) UnmarshalJSON

func (l *IDList) UnmarshalJSON(data []byte) error

UnmarshalJSON overrides to assure a proper unmarshal.

type List

type List struct {
	Type  string        `json:"@type"`
	Value []interface{} `json:"@value"`
}

List is used in Gremlin v3.0+ instead of arrays in some cases.

type Property

type Property struct {
	// Type is the Gremlin-type. For this particular
	// structure it typically will be "g:VertexProperty"
	Type string `json:"@type"`
	// Value stores the actual data of the Property.
	// This would be its Key, Value, and ID.
	Value PropertyValue `json:"@value"`
}

Property holds the type and value of the property. It's extra information used by PropertyDetail.

func NewProperty

func NewProperty(label string, value interface{}) Property

NewProperty will just shorten the struggle of filling a property struct. This is meant to be used when creating a Vertex struct.

func UnmarshalPropertyList

func UnmarshalPropertyList(data [][]byte) ([]Property, error)

UnmarshalPropertyList is a utility to unmarshal a list or array of IDs properly.

func (*Property) GetLabel

func (p *Property) GetLabel() string

GetLabel will return the key that is used to find this particular property and its value.

func (*Property) GetValue

func (p *Property) GetValue() interface{}

GetValue is a shortcut for taking the raw interface{} from the property itself without redundancy.

type PropertyDetailedValue

type PropertyDetailedValue struct {
	Value interface{} `json:"@value"`
	Type  string      `json:"@type,omitempty"`
}

PropertyDetailedValue holds the value and optional type depending on how the whole struct can unmarshal into a string or not. If not then the type is listed.

type PropertyID

type PropertyID struct {
	Type  string      `json:"@type"`
	Value interface{} `json:"@value"`
}

PropertyID holds the ID that is used for the property itself.

type PropertyList

type PropertyList struct {
	Properties []Property
	// contains filtered or unexported fields
}

PropertyList is used for unmarshalling after querying. We use this instead of []Edge for Gremlin v3.0 compatibility.

func (*PropertyList) UnmarshalJSON

func (l *PropertyList) UnmarshalJSON(data []byte) error

UnmarshalJSON overrides to assure a proper unmarshal.

type PropertyMap

type PropertyMap map[string][]Property

PropertyMap is the map used to hold the properties itself. the string key is equivalent to the Gremlin key and the []Property is the value. Properties can have multiple values; this is why we must have it as a slice of Property.

type PropertyValue

type PropertyValue struct {
	ID    PropertyID   `json:"id"`
	Value ValueWrapper `json:"value"`
	Label string       `json:"label"`
}

PropertyValue contains the ID, value, and label of this property's value.

type SimpleValue

type SimpleValue struct {
	Type  string      `json:"@type"`
	Value interface{} `json:"@value"`
}

SimpleValue is used to unmarshal simple value responses from the TinkerPop server. These can include simple datatypes like Int, String, Double, Bool, etc.

type ValueWrapper

type ValueWrapper struct {
	PropertyDetailedValue
	Partial bool `json:"-"`
}

ValueWrapper will handle storing the correct value into the correct spot in this struct for not confusion.

func (*ValueWrapper) UnmarshalJSON

func (w *ValueWrapper) UnmarshalJSON(data []byte) error

UnmarshalJSON will override the unmarshal process of ValueWrapper and store the correct Value into the variables within the struct.

type Vertex

type Vertex struct {
	Type  string      `json:"@type"`
	Value VertexValue `json:"@value"`
}

Vertex maintains pointers to both a set of incoming and outgoing Edge objects. The outgoing edges are the edges for which the Vertex is a tail. The incoming edges are those edges for which the Vertex is the head.

TinkerPop: http://tinkerpop.apache.org/javadocs/3.2.1/core/org/apache/tinkerpop/gremlin/structure/Vertex.html

---inEdges---> vertex ---outEdges--->.

func NewVertex

func NewVertex(label string, properties ...interface{}) Vertex

NewVertex is to create a Vertex struct without all the hassle.

func UnmarshalVertexList

func UnmarshalVertexList(data [][]byte) ([]Vertex, error)

UnmarshalVertexList is a utility to unmarshal a list or array of vertices properly.

func (*Vertex) AddEdge

func (v *Vertex) AddEdge(client queryClient, label string, outVID interface{}, properties ...interface{}) (Edge, error)

AddEdge adds an outgoing edge from this Vertex object to another Vertex object via its unique ID.

func (*Vertex) AddProperty

func (v *Vertex) AddProperty(client queryClient, key string, value interface{}) error

AddProperty will add a property to the vertex in the graph and return a new version of the vertex with the property added to it in the structure.

func (*Vertex) Drop

func (v *Vertex) Drop(client queryClient) error

Drop will drop the current vertex that's being called from.

func (*Vertex) DropProperties

func (v *Vertex) DropProperties(client queryClient, properties ...string) error

DropProperties drops the properties from the vertex so they don't exist.

func (*Vertex) ID

func (v *Vertex) ID() interface{}

ID will retrieve the Vertex ID for you without having to traverse all the way through the structures.

func (*Vertex) Label

func (v *Vertex) Label() string

Label retrieves the label of the vertex without having to traverse all the wya through the structures.

func (*Vertex) PropertyMap

func (v *Vertex) PropertyMap() PropertyMap

PropertyMap returns a copy of the properties in a map within the Vertex itself. Altering this copy will not affect the vertex on the graph.

func (*Vertex) PropertyValue

func (v *Vertex) PropertyValue(key string, index int) interface{}

PropertyValue returns the value of a property without having to traverse all the way through the structures.

func (*Vertex) QueryBothEdges

func (v *Vertex) QueryBothEdges(client queryClient, labels ...string) ([]Edge, error)

QueryBothEdges will execute bothE() on this vertex for you without having to make another lengthy call to ExecuteQuery.

func (*Vertex) QueryInEdges

func (v *Vertex) QueryInEdges(client queryClient, labels ...string) ([]Edge, error)

QueryInEdges will execute inE() on this vertex for you without having to make another lengthy call to ExecuteQuery.

func (*Vertex) QueryOutEdges

func (v *Vertex) QueryOutEdges(client queryClient, labels ...string) ([]Edge, error)

QueryOutEdges will execute outE() on this vertex for you without having to make another lengthy call to ExecuteQuery.

func (*Vertex) QueryRefresh

func (v *Vertex) QueryRefresh(client queryClient) error

QueryRefresh gets the vertex from the graph and refreshes its values to match.

func (*Vertex) Traversal

func (v *Vertex) Traversal() traversal.String

Traversal returns a new query string that is directed to the current vertex being referenced.

type VertexList

type VertexList struct {
	Vertices []Vertex
	// contains filtered or unexported fields
}

VertexList is used for unmarshalling after querying. We use this instead of []Vertex for Gremlin v3.0 compatibility.

func (*VertexList) UnmarshalJSON

func (l *VertexList) UnmarshalJSON(data []byte) error

UnmarshalJSON overrides to assure a proper unmarshal.

type VertexValue

type VertexValue struct {
	ID         interface{} `json:"id"`
	Label      string      `json:"label"`
	Properties PropertyMap `json:"properties,omitempty"`
}

VertexValue contains the 'value' data from the Vertex object.

Jump to

Keyboard shortcuts

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