db

package
v0.0.0-...-af33e7b Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: BSD-3-Clause, MIT Imports: 1 Imported by: 0

Documentation

Overview

Package db is the basic contract package for a database handled by goneo.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseService

type DatabaseService interface {
	NewNode(labels ...string) Node

	GetNode(id int) (Node, error)
	GetAllNodes() []Node

	GetRelation(id int) (Relation, error)
	GetAllRelations() []Relation

	FindPath(start, end Node) Path

	FindNodeByProperty(prop, value string) []Node

	Close()
}

type Direction

type Direction int
const (
	Both Direction = iota
	Incoming
	Outgoing
)

func DirectionFromString

func DirectionFromString(str string) Direction

DirectionFromString converts a string to a direction

Example
fmt.Println(DirectionFromString("out") == Outgoing)
Output:

true

func (Direction) String

func (d Direction) String() string

type Node

type Node interface {
	Id() int
	String() string
	Property(prop string) interface{}
	Properties() map[string]string
	SetProperty(name, val string)
	HasProperty(prop string) bool
	HasLabel(labels ...string) bool
	Labels() []string
	RelateTo(end Node, relType string) Relation
	Relations(dir Direction) []Relation
}

type Path

type Path interface {
	Nodes() []Node
	Relations() []Relation
	Items() []PropertyContainer

	String() string
}

Path encapsulates a simple path in a graph

type PathBuilder

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

PathBuilder provides a way to build a path.

func NewPathBuilder

func NewPathBuilder(start Node) *PathBuilder
Example
var start Node = &mocknode{"a"}
var end Node = &mocknode{"b"}
var rel = start.RelateTo(end, "HAS")

builder := NewPathBuilder(start)
builder = builder.Append(rel)
path := builder.Build()
fmt.Println(path.String())
Output:

(a)-[:HAS]->(b)

func (*PathBuilder) Append

func (builder *PathBuilder) Append(rel Relation) *PathBuilder

func (*PathBuilder) Build

func (builder *PathBuilder) Build() Path

func (*PathBuilder) Last

func (builder *PathBuilder) Last() Node

type PropertyContainer

type PropertyContainer interface {
	Property(string) interface{}
	Id() int
	String() string
}

PropertyContainer encapsulates graph nodes and edges so they can be handled interchangeably for output.

type Relation

type Relation interface {
	Id() int
	String() string
	Start() Node
	End() Node
	Type() string

	Property(prop string) interface{}
	Properties() map[string]interface{}
	SetProperty(nam string, val interface{})
}

Directories

Path Synopsis
Package mem is a simple memory based implementation of DatabaseService.
Package mem is a simple memory based implementation of DatabaseService.
Package simplefile for a simple file backed DatabaseService.
Package simplefile for a simple file backed DatabaseService.

Jump to

Keyboard shortcuts

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