talon

package
v0.0.0-...-a7a3610 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Unmarshalers = make(map[string]UnmarshalType)

Unmarshalers is a map of type keys to GenUnmarshaler functions for fetching types that convert strings into useful values for use.

Functions

func Close

func Close()

Close exits primarly to match Rows return behavior. When you run `Query` you have to close the rows object yourself. This is just here to prevent breakages.

Types

type Complex

type Complex complex128

Complex wraps the native go complex128 type to allow conversion between complex values in Go and a string used to store such values in the database.

func NewComplex

func NewComplex(i interface{}) Complex

NewComplex converts the complex64 or complex128 values into a Complex type for marshaling but if another type is given this returns 0.

func (Complex) MarshalTalon

func (c Complex) MarshalTalon() ([]byte, error)

MarshalTalon takes a complex value and turns it into a string representation of itself.

func (*Complex) UnmarshalTalon

func (c *Complex) UnmarshalTalon(bs []byte) error

UnmarshalTalon takes a string and should it parse correctly

type ComplexParseError

type ComplexParseError string

ComplexParseError represents an error that occurred while parsing a complex value in string format.

func (ComplexParseError) Error

func (cpe ComplexParseError) Error() string

Errror returns the message associated with this parse error.

type ConnectOptions

type ConnectOptions struct {
	User string
	Pass string
	Host string
	Port uint16
	Pool uint16
}

ConnectOptions allows customiztaino of how to connect to a Neo4j database with talon.

func (ConnectOptions) Connect

func (co ConnectOptions) Connect() (db *DB, err error)

Connect will take the provided connection options and attempt to establish a connection to a Neo4j database.

func (*ConnectOptions) URL

func (co *ConnectOptions) URL() string

URL takes the options set for connection and generates a bolt connection string.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB represents a talon connection to a Neo4j database using Neo4j bolt behind the scenes.

func (*DB) Cypher

func (d *DB) Cypher(cypher string) *Query

Cypher returns a query read to run on Neo4j from a raw Cypher string. This method assumes there are no properties to be added to the query.

func (*DB) CypherP

func (d *DB) CypherP(cypher string, p Properties) (*Query, error)

CypherP performs the same job as Cypher, it just allows the user to pass in a set of properties.

func (*DB) MustCypherP

func (d *DB) MustCypherP(cypher string, p Properties) *Query

MustCypherP calls MustCypher but will panic on error.

type Driver

type Driver interface {
	Conn() (bolt.Conn, error)
}

Driver is an interface defining the requirement of a method that returns a bolt connection or error.

type JSON

type JSON struct {
	Data interface{}
}

JSON wraps an interface to provide a means for impelmenting the talon marshaling library.

func NewJSON

func NewJSON(i interface{}) *JSON

NewJSON returns a pointer to the JSON type as a helper.

func (*JSON) Map

func (j *JSON) Map() map[string]interface{}

Map returns the data (or nil) that is contained within this JSON value as a map[string]interface{}

func (*JSON) MarshalTalon

func (j *JSON) MarshalTalon() ([]byte, error)

MarshalTalon implements the talon.Marshaler interface for the JSON type.

func (*JSON) Slice

func (j *JSON) Slice() []interface{}

Slice returns the data (or nil) that is contained within this JSON value as a []interface{}

func (*JSON) UnmarshalTalon

func (j *JSON) UnmarshalTalon(bs []byte) error

UnmarshalTalon converts the JSON string back into a go type

type JSONParseError

type JSONParseError string

JSONParseError represents an error parsing a JSON value stored in Neo4j

func (JSONParseError) Error

func (jpe JSONParseError) Error() string

Error allows JSONParseError to match the error interface.

type Marshaler

type Marshaler interface {
	MarshalTalon() ([]byte, error)
}

Marshaler represents a type that can turn itself into a string representation suitable for use with Talon query building.

type Metadata

type Metadata struct {
	Fields []string
	// contains filtered or unexported fields
}

Metadata contains details about the rows response, such as the field names from the query.

type Node

type Node struct {
	ID         int64
	Labels     []string
	Properties Properties
}

Node represents a Neo4j Node type.

func (*Node) Get

func (n *Node) Get(key string) interface{}

Get will fetch the property assocaited with the node, returning a bool to signify if the property did exist.

func (*Node) GetBool

func (n *Node) GetBool(key string) (bool, bool)

GetBool is similar to Get except it attempts to convert the found value to a bool (if it is a bool). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Node) GetFloat

func (n *Node) GetFloat(key string) (float64, bool)

GetFloat is similar to get except it attempts to convert the found value to a float64 (if it is a float32 or float64). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Node) GetInt

func (n *Node) GetInt(key string) (int64, bool)

GetInt is similar to get except it handles fetching any integer type and converts it to an int64 (if it is any sized integer). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Node) GetString

func (n *Node) GetString(key string) (string, bool)

GetString performs the same function as get, except it handles fetching a string or string pointer value (if it is a string). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Node) Set

func (n *Node) Set(key string, val interface{})

Set will assign the given value to the associated Key.

type Path

type Path []interface{}

Path represents a graph path, like node a -> rel 1 -> node b -> rel 2 -> node c or what-have-you.

type Properties

type Properties map[string]interface{}

Properties is a map[string]interface{} wrapper with a special string function designed to produce properties for Neo4j.

func (Properties) Keys

func (p Properties) Keys() []string

Keys returns an array of string values representing the keys in the map.

func (Properties) MarshalTalon

func (p Properties) MarshalTalon() ([]byte, error)

MarshalTalon will marshal the Properties object using JSON.

func (Properties) MarshaledProperties

func (p Properties) MarshaledProperties() (Properties, error)

MarshaledProperties will attempt to TalonMarshal all property values that can be marshaled.

func (Properties) Merge

func (p Properties) Merge(other Properties) Properties

Merge merges the current Properties key/value pairs with those of the given Properties object. This does not modify the current or other input objects it instead returns a new Property map representing the merged properties.

func (Properties) QueryString

func (p Properties) QueryString() string

QueryString produces a string of key: {key} mappings based on the structure of this object for use in queries.

func (Properties) String

func (p Properties) String() string

String brings Properties inline with fmt.Stringer

func (*Properties) UnmarshalTalon

func (p *Properties) UnmarshalTalon(bs []byte) error

UnmarshalTalon will convert a JSON value back into a properties value.

func (Properties) UnmarshaledProperties

func (p Properties) UnmarshaledProperties() (Properties, error)

UnmarshaledProperties assumes that properties are raw strings from the database and examines them for potential type values.

type Query

type Query struct {
	// contains filtered or unexported fields
}

Query reprsents a Talon query before it's been converted in Cypher

func (*Query) Exec

func (q *Query) Exec() (*Result, error)

Exec runs a query that doesn't expect rows to be returned.

func (*Query) Query

func (q *Query) Query() (*Rows, error)

Query executes a fetch query, expecting rows to be returned.

func (*Query) ToCypher

func (q *Query) ToCypher() string

ToCypher converts a query object into a Cypher query string. NOTE: For the time being raw queries (strings with property injection)

are the only types of queries supported.

type Relationship

type Relationship struct {
	ID          int64
	StartNodeID int64
	EndNodeID   int64
	Name        string
	Properties  Properties
	Bounded     bool
}

Relationship represents a link between two nodes, it can come in two different kinds -- bounded or unbounded. If it's bounded then StartNodeID and EndNodeID will be set (and Bounded will be true). If it's unbounded these values will be 0.

func (*Relationship) Get

func (r *Relationship) Get(key string) (val interface{}, ok bool)

Get will fetch the property assocaited with the relationship, returning a bool to signify if the property did exist.

func (*Relationship) GetBool

func (r *Relationship) GetBool(key string) (bool, bool)

GetBool is similar to Get except it attempts to convert the found value to a bool (if it is a bool). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Relationship) GetFloat

func (r *Relationship) GetFloat(key string) (float64, bool)

GetFloat is similar to get except it attempts to convert the found value to a float64 (if it is a float32 or float64). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Relationship) GetInt

func (r *Relationship) GetInt(key string) (int64, bool)

GetInt is similar to get except it handles fetching any integer type and converts it to an int64 (if it is any sized integer). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Relationship) GetString

func (r *Relationship) GetString(key string) (string, bool)

GetString performs the same function as get, except it handles fetching a string or string pointer value (if it is a string). Unlike Get, the type Get methods will return 'false' for it's second return if the value is not of the requested type.

func (*Relationship) Set

func (r *Relationship) Set(key string, val interface{})

Set will assign the given value to the associated Key.

type Result

type Result struct {
	Stats ResultStats
	Type  string
}

Result represents a return from a non-row based query like a create/delete or upate where you're not using something like "return" in the query.

type ResultStats

type ResultStats struct {
	LabelsAdded          int64
	NodesCreated         int64
	PropertiesSet        int64
	NodesDeleted         int64
	RelationshipsCreated int64
	RelationshipsDeleted int64
}

ResultStats are some details about the results of the query, such as the number of of nodes, labels and properties added/set.

type Row

type Row struct {
	Metadata *Metadata
	// contains filtered or unexported fields
}

Row represents a list of graph entities.

func (*Row) GetColumn

func (r *Row) GetColumn(label string) (interface{}, bool)

GetColumn fetchs a column by it's associated name, so if you return the name 'node' in your query, you can fetch the value for that column via GetColumn("node").

func (*Row) GetIndex

func (r *Row) GetIndex(idx int) (interface{}, bool)

GetIndex returns the column by index, along with a bool no whether the index existed.

func (*Row) Len

func (r *Row) Len() int

Len returns the number of fields contained in the row.

type Rows

type Rows struct {
	Metadata *Metadata
	// contains filtered or unexported fields
}

Rows represents a group of rows fetched from a Cypher query.

func (*Rows) All

func (r *Rows) All() ([]*Row, error)

All returns all the rows up front instead of using the streaming API.

func (*Rows) Close

func (r *Rows) Close()

Close will close the incoming stream of graph entities.

func (*Rows) IsOpen

func (r *Rows) IsOpen() bool

IsOpen will return whether or not the Rows value has been closed or not, most likely you won't need this but in cases were a row value might be closed somewhere else, you can check before operating on it.

func (*Rows) Next

func (r *Rows) Next() (*Row, error)

Next fetches the next row in the resultset.

type UnmarshalType

type UnmarshalType func([]byte) (interface{}, error)

UnmarshalType is a function that will take in a byte value and return an interface type (or error) when trying to Unmarshal.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalTalon([]byte) error
}

Unmarshaler represents a type that is capable of converting a byte array into a Go valid representation of itself. If the byte array is malformed, then an error can be returned.

Jump to

Keyboard shortcuts

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