graphdb

package
v1.4.2-0...-309eec2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonUniqueNameError

func IsNonUniqueNameError(err error) bool

func PathDepth

func PathDepth(p string) int

Returns the depth or number of / in a given path

Types

type Database

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

Graph database for storing entities and their relationships

func NewDatabase

func NewDatabase(conn *sql.DB) (*Database, error)

Create a new graph database initialized with a root entity

func NewSqliteConn

func NewSqliteConn(root string) (*Database, error)

func (*Database) Children

func (db *Database) Children(name string, depth int) ([]WalkMeta, error)

Return the children of the specified entity

func (*Database) Close

func (db *Database) Close() error

Close the underlying connection to the database

func (*Database) Delete

func (db *Database) Delete(name string) error

Delete the reference to an entity at a given path

func (*Database) Exists

func (db *Database) Exists(name string) bool

Return true if a name already exists in the database

func (*Database) Get

func (db *Database) Get(name string) *Entity

Return the entity for a given path

func (*Database) List

func (db *Database) List(name string, depth int) Entities

List all entities by from the name The key will be the full path of the entity

func (*Database) Parents

func (db *Database) Parents(name string) ([]string, error)

Return the parents of a specified entity

func (*Database) Purge

func (db *Database) Purge(id string) (int, error)

Remove the entity with the specified id Walk the graph to make sure all references to the entity are removed and return the number of references removed

func (*Database) RefPaths

func (db *Database) RefPaths(id string) Edges

Return all the id's path references

func (*Database) Refs

func (db *Database) Refs(id string) int

Return the refrence count for a specified id

func (*Database) Rename

func (db *Database) Rename(currentName, newName string) error

Rename an edge for a given path

func (*Database) RootEntity

func (db *Database) RootEntity() *Entity

Return the root "/" entity for the database

func (*Database) Set

func (db *Database) Set(fullPath, id string) (*Entity, error)

Set the entity id for a given path

func (*Database) Walk

func (db *Database) Walk(name string, walkFunc WalkFunc, depth int) error

Walk through the child graph of an entity, calling walkFunc for each child entity. It is safe for walkFunc to call graph functions.

type Edge

type Edge struct {
	EntityID string
	Name     string
	ParentID string
}

An Edge connects two entities together

type Edges

type Edges []*Edge

type Entities

type Entities map[string]*Entity

func (Entities) Paths

func (e Entities) Paths() []string

Return the paths sorted by depth

type Entity

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

Entity with a unique id

func (*Entity) ID

func (e *Entity) ID() string

Return the id used to reference this entity

type WalkFunc

type WalkFunc func(fullPath string, entity *Entity) error

type WalkMeta

type WalkMeta struct {
	Parent   *Entity
	Entity   *Entity
	FullPath string
	Edge     *Edge
}

Jump to

Keyboard shortcuts

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