api

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(value string) string

Escape escapes all values that are not allowed to be stored directly into the cosmos-db.

func NewEdgeG

func NewEdgeG(g interfaces.Graph) interfaces.Edge

func NewEdgeV

func NewEdgeV(v interfaces.Vertex) interfaces.Edge

func NewGraph

func NewGraph(name string) interfaces.Graph

NewGraph creates a new graph query with the given name Hint: The actual graph has to exist on the server in order to execute the query that will be generated with this query builder

func NewPropertyV

func NewPropertyV(v interfaces.Vertex) interfaces.Property

func NewSimpleQB

func NewSimpleQB(format string, a ...interface{}) interfaces.QueryBuilder

func NewVertexE

func NewVertexE(e interfaces.Edge) interfaces.Vertex

func NewVertexG

func NewVertexG(g interfaces.Graph) interfaces.Vertex

func SetQueryLanguageTo

func SetQueryLanguageTo(ql QueryLanguage)

SetQueryLanguageTo sets the query language that shall be used. Per default QueryLanguageCosmosDB is in use.

func ShouldEscape

func ShouldEscape(value string) bool

ShouldEscape returns true in case the given string needs to be escaped.

func ShouldUnescape

func ShouldUnescape(value string) bool

ShouldUnescape returns true in case the given string needs to be unescaped.

func ToValueMap

func ToValueMap(input []byte) (map[string]TypedValue, error)

ToValueMap converts the given input byte array into a map of TypedValue's. The method will fail in case the data in the given byte array does not consist of key value pairs where these values are primitive types.

func UnEscape

func UnEscape(value string) string

UnEscape reverses potentially applied escaping. In case of an error the original input value will be returned

Types

type Edge

type Edge struct {
	ID        string `mapstructure:"id"`
	Label     string `mapstructure:"label"`
	Type      Type   `mapstructure:"type"`
	InVLabel  string `mapstructure:"inVLabel"`
	InV       string `mapstructure:"inV"`
	OutVLabel string `mapstructure:"outVLabel"`
	OutV      string `mapstructure:"outV"`
}

Edge represents the cosmos DB type for an edge. As it would be returned by a call to g.E().

func ToEdges

func ToEdges(input []byte) ([]Edge, error)

ToEdges converts the given input byte array into an array of Edge type. The method will fail in case the data in the given byte array does not contain values of type edge.

func (Edge) String

func (e Edge) String() string

type Property

type Property struct {
	ID    string     `mapstructure:"id"`
	Value TypedValue `mapstructure:"value,squash"`
	Label string     `mapstructure:"label"`
}

Property represents the cosmos db type for a property. As it would be returned by a call to .properties().

func ToProperties

func ToProperties(input []byte) ([]Property, error)

ToProperties converts the given input byte array into an array of Property type. The method will fail in case the data in the given byte array does not contain values of type property.

type QueryLanguage

type QueryLanguage string
const (
	QueryLanguageCosmosDB         QueryLanguage = "cosmos"
	QueryLanguageTinkerpopGremlin QueryLanguage = "tinkerpop"
)

type ResponseArray

type ResponseArray []interfaces.Response

ResponseArray an array type for responses

func (ResponseArray) ToEdges

func (responses ResponseArray) ToEdges() ([]Edge, error)

ToEdges converts the given ResponseArray into an array of Edge type. The method will fail in case the data in the given ResponseArray does not contain values of type edge.

func (ResponseArray) ToProperties

func (responses ResponseArray) ToProperties() ([]Property, error)

ToProperties converts the given ResponseArray into an array of Property type. The method will fail in case the data in the given ResponseArray does not contain values of type property.

func (ResponseArray) ToValues

func (responses ResponseArray) ToValues() ([]TypedValue, error)

ToValues converts the given ResponseArray into an array of TypedValue type. The method will fail in case the data in the given ResponseArray does not contain primitive values.

func (ResponseArray) ToVertices

func (responses ResponseArray) ToVertices() ([]Vertex, error)

ToVertices converts the given ResponseArray into an array of Vertex type. The method will fail in case the data in the given ResponseArray does not contain values of type vertex.

type Type

type Type string

Type defines the cosmos db complex types

const (
	TypeVertex Type = "vertex"
	TypeEdge   Type = "edge"
)

type TypedValue

type TypedValue struct {
	Value interface{}
}

TypedValue represents the cosmos DB type for a value in case it is not used/ attached to a complex type.

func ToValues

func ToValues(input []byte) ([]TypedValue, error)

ToValues converts the given input byte array into an array of TypedValue type. The method will fail in case the data in the given byte array does not contain primitive values.

func (TypedValue) AsBool

func (tv TypedValue) AsBool() bool

func (TypedValue) AsBoolE

func (tv TypedValue) AsBoolE() (bool, error)

func (TypedValue) AsFloat64

func (tv TypedValue) AsFloat64() float64

func (TypedValue) AsFloat64E

func (tv TypedValue) AsFloat64E() (float64, error)

func (TypedValue) AsInt32

func (tv TypedValue) AsInt32() int32

func (TypedValue) AsInt32E

func (tv TypedValue) AsInt32E() (int32, error)

func (TypedValue) AsString

func (tv TypedValue) AsString() string

func (TypedValue) AsStringE

func (tv TypedValue) AsStringE() (string, error)

func (TypedValue) String

func (tv TypedValue) String() string

type ValueWithID

type ValueWithID struct {
	ID    string     `mapstructure:"id"`
	Value TypedValue `mapstructure:"value,squash"`
}

ValueWithID represents the cosmos DB type for a value in case it is used/ attached to a complex type.

type Vertex

type Vertex struct {
	Type       Type              `mapstructure:"type"`
	ID         string            `mapstructure:"id"`
	Label      string            `mapstructure:"label"`
	Properties VertexPropertyMap `mapstructure:"properties"`
}

Vertex represents the cosmos DB type for an vertex. As it would be returned by a call to g.V().

func ToVertices

func ToVertices(input []byte) ([]Vertex, error)

ToVertices converts the given input byte array into an array of Vertex type. The method will fail in case the data in the given byte array does not contain values of type vertex.

func (Vertex) String

func (v Vertex) String() string

type VertexPropertyMap

type VertexPropertyMap map[string][]ValueWithID

func (VertexPropertyMap) AsInt32

func (vpm VertexPropertyMap) AsInt32(key string) (int32, error)

func (VertexPropertyMap) AsString

func (vpm VertexPropertyMap) AsString(key string) (string, error)

func (VertexPropertyMap) Value

func (vpm VertexPropertyMap) Value(key string) (ValueWithID, bool)

Value returns the first value of the properties for this key the others are ignored. Anyway it is not possible to store multiple values for one property key.

Jump to

Keyboard shortcuts

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