redisgraphgowrapper

package module
v0.0.0-...-6ba055e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

README

redis-graph-go-wrapper

Wrapper library for working with redis graphs

Install

go get github.com/rlama531/redis-graph-go-wrapper

Why redis-graph-go-wrapper?

This wrapper is meant to provide an easier way of interacting with the standard https://github.com/RedisGraph/redisgraph-go, which was a little difficult to use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisConnection

func NewRedisConnection(addr string, pass string) redis.Conn

Types

type EdgeDirection

type EdgeDirection int32
const (
	Undirected EdgeDirection = iota
	Directed
)

type RedisGraphProvider

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

func NewRedisConnectionGraphProvider

func NewRedisConnectionGraphProvider(conn redis.Conn, graphName string) *RedisGraphProvider

func (*RedisGraphProvider) AddEdge

func (g *RedisGraphProvider) AddEdge(edgeDirection EdgeDirection, srcNodeID string, destNodeID string, relation string, properties map[string]interface{}) error

AddEdge will add an edge which can directed (from the specified srcNodeID to the destNodeID) or undirected. The srcNodeID and destNodeID params refer to the "id" properties on the nodes, the relation param specifies the type of relationship, and the properties map must include "id" for the edge.

func (*RedisGraphProvider) AddNode

func (g *RedisGraphProvider) AddNode(label string, alias string, properties map[string]interface{}) error

AddNode adds a node to the graph. It requires a label to identify the type of node, an optional alias string, and a properities map[string]interface{}. In the properties map, "id" key must be present.

func (*RedisGraphProvider) ClearGraph

func (g *RedisGraphProvider) ClearGraph()

ClearGraph deletes the graph created by the provider.

func (*RedisGraphProvider) GetAllEdges

func (g *RedisGraphProvider) GetAllEdges() ([]*rg.Edge, error)

GetAllEdges grabs all edges that exist in the graph .

func (*RedisGraphProvider) GetAllNodes

func (g *RedisGraphProvider) GetAllNodes() ([]*rg.Node, error)

GetAllNodes returns a list of all the nodes present in the graph

func (*RedisGraphProvider) GetAllNodesWithLabel

func (g *RedisGraphProvider) GetAllNodesWithLabel(label string) ([]*rg.Node, error)

GetAllNodesWithLabel grabs all nodes with the matching label string.

func (*RedisGraphProvider) GetAllNodesWithLabels

func (g *RedisGraphProvider) GetAllNodesWithLabels(labels []string) ([]*rg.Node, error)

GetAllNodesWithLabels grabs all nodes that match any of the labels string slice.

func (*RedisGraphProvider) GetAllNodesWithProperties

func (g *RedisGraphProvider) GetAllNodesWithProperties(properties map[string]interface{}, fullMatch bool) ([]*rg.Node, error)

GetAllNodesWithProperties will return the nodes that match the properties given. If fullMatch is true, then the func will only return nodes that match all the properties given. If false, then it will return all nodes that match at least one of the properties given.

func (*RedisGraphProvider) GetEdgesByNodeIDs

func (g *RedisGraphProvider) GetEdgesByNodeIDs(srcNodeID string, destNodeID string, optionalRelation string) ([]*rg.Edge, error)

GetEdgesByRelations grabs all edges that exist in the graph that match the given relations.

func (*RedisGraphProvider) GetEdgesByRelation

func (g *RedisGraphProvider) GetEdgesByRelation(relation string) ([]*rg.Edge, error)

GetEdgesByRelation grabs all edges that exist in the graph that match the given relation

func (*RedisGraphProvider) GetEdgesByRelations

func (g *RedisGraphProvider) GetEdgesByRelations(relations []string) ([]*rg.Edge, error)

GetEdgesByRelations grabs all edges that exist in the graph that match the given relations.

func (*RedisGraphProvider) GetNodeByID

func (g *RedisGraphProvider) GetNodeByID(srcNodeID string) (*rg.Node, error)

GetNodeByID grabs a node by the id property.

func (*RedisGraphProvider) GetNthDegreeNodesByRelation

func (g *RedisGraphProvider) GetNthDegreeNodesByRelation(srcNodeID string, relation string, nthDegree int, destNodeProperties map[string]interface{}) ([]*rg.Node, error)

getNthDegreeNodesByRelationAndDestNodeProperities will return all the nthDegree nodes that are related to the src node via the relation paramter. It can return nodes that are also related on fewer degrees. For example, if nodeA is connected to nodeB by 1st and 2nd degree, using this func with 2 as the nthDegree will return it, even though it is also a 1st degree connection.

func (*RedisGraphProvider) GetNthDegreeNodesByRelationAndExcludeShorterDegree

func (g *RedisGraphProvider) GetNthDegreeNodesByRelationAndExcludeShorterDegree(srcNodeID string, relation string, nthDegree int, destNodeProperties map[string]interface{}) ([]*rg.Node, error)

GetNthDegreeNodesByRelationAndExcludeShorterDegree will return all the nthDegree nodes with destNodeProperties that are related to the src node via the relation paramter. It will NOT return nodes of the nth degree that also have a shorter degree. For example, if nodeA is connected to nodeB by 1st and 2nd degree, using this func with 2 as the nthDegree will NOT return it since it is also a 1st degree connection.

Jump to

Keyboard shortcuts

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