api

package
v0.1.40 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddV added in v0.1.13

func AddV(label string) interfaces.Vertex

AddV adds .addV('<label>'), e.g. .addV('user'), to the query. The query call adds a vertex with the given label and returns that vertex.

func Constant added in v0.1.13

func Constant(c string) interfaces.QueryBuilder

Constant adds .constant() to the query.

func Eq added in v0.1.34

func Eq[T any](v T) interfaces.QueryBuilder

Eq adds .eq(<T>) to the query. (equal)

func Escape

func Escape(value string) string

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

func Gt added in v0.1.34

func Gt[T Ordered](v T) interfaces.QueryBuilder

Gt adds .gt(<T>) to the query. (greater than)

func Gte added in v0.1.34

func Gte[T Ordered](v T) interfaces.QueryBuilder

Gte adds .gte(<T>) to the query. (greater than equal)

func Has added in v0.1.19

func Has(key string, value ...interface{}) interfaces.QueryBuilder

Has adds .has("<key>","<value>"), e.g. .has("name","hans") depending on the given type the quotes for the value are omitted. e.g. .has("temperature",23.02) or .has("available",true) The method can also be used to return vertices that have a certain property. Then .has("<prop name>") will be added to the query.

v.Has("prop1")

func InE added in v0.1.13

func InE(labels ...string) interfaces.Edge

InE adds .inE([<label_1>,<label_2>,..,<label_n>]), to the query. The query call returns all incoming edges of the Vertex

func InV added in v0.1.29

func InV() interfaces.Vertex

InV adds .inV(), to the query. The query call returns all incoming vertex of the edge

func Lt added in v0.1.34

func Lt[T Ordered](v T) interfaces.QueryBuilder

Lt adds .lt(<T>) to the query. (less than)

func Lte added in v0.1.34

func Lte[T Ordered](v T) interfaces.QueryBuilder

Lte adds .lte(<T>) to the query. (less than equal)

func Neq added in v0.1.34

func Neq[T Ordered](v T) interfaces.QueryBuilder

Neq adds .neq(<T>) to the query. (not equal)

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 added in v0.1.7

func NewPropertyV(v interfaces.Vertex) interfaces.Property

func NewSimpleQB

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

func NewValueV added in v0.1.40

func NewValueV(e interfaces.Vertex) interfaces.Value

func NewVertexE

func NewVertexE(e interfaces.Edge) interfaces.Vertex

func NewVertexG

func NewVertexG(g interfaces.Graph) interfaces.Vertex

func OutE added in v0.1.13

func OutE(labels ...string) interfaces.Edge

OutE adds .outE([<label_1>,<label_2>,..,<label_n>]), to the query. The query call returns all outgoing edges of the Vertex

func OutV added in v0.1.16

func OutV() interfaces.Vertex

OutV adds .outV(), to the query. The query call returns all outgoing vertex of the edge

func SetQueryLanguageTo added in v0.1.3

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 added in v0.1.1

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

func Unfold added in v0.1.13

func Unfold() interfaces.QueryBuilder

Unfold adds .unfold() to the query.

func Within added in v0.1.35

func Within(values ...string) interfaces.QueryBuilder

Within adds .within([<value_1>,<value_1>,..,<value_n>]), to the query. Where values are of type string.

func WithinInt added in v0.1.35

func WithinInt(values ...int) interfaces.QueryBuilder

WithinInt adds .within([<value_1>,<value_1>,..,<value_n>]), to the query. Where values are of type int.

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 Ordered added in v0.1.39

type Ordered interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
}

Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >.

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 added in v0.1.3

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) AsInt64E added in v0.1.28

func (tv TypedValue) AsInt64E() (int64, 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 ToVertex added in v0.1.27

func ToVertex(input interface{}) (Vertex, error)

ToVertex casts the given object into a vertex

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