ograph

package module
v0.0.0-...-da7ae81 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2014 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

ograph is a graph database that uses postgresql as the backend store.

each node have a list of attributes (encoded as JSON), a unique name, and a list of relations

relations can also have attributes, all relations are directed, have a name and two endpoints.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	// ErrNotFound: Unable to find a Node or Relation in the graph
	ErrNotFound = ApiError("not found")

	// ErrInvalidEncoding: The attributes of a node aren't encoded as utf-8 objects
	ErrInvalidEncoding = ApiError("attributes must be a utf-8 encoded json")

	ErrAbortedByUser = ApiError("user aborted the transaction")

	// A Invalid Node id
	InvalidNid = Nid(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiError

type ApiError string

Represents an error

func (ApiError) Error

func (a ApiError) Error() string

Error implements the error interface

type Attributes

type Attributes string

The attributes of a Node or Relation

type G

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

The object graph

func (*G) Close

func (g *G) Close() error

func (*G) Node

func (g *G) Node(id Nid, name string, out *Node) (*Node, error)

func (*G) SaveAll

func (g *G) SaveAll(what ...interface{}) error

func (*G) Use

func (g *G) Use(repo *data.Repo)

func (*G) Walk

func (g *G) Walk(from *Node, using string) (RelationSet, error)

type Identity

type Identity struct {
	Gid Nid
}

Identity is used to allow other apis to refer to a given node for later use.

type Nid

type Nid uint64

A Nid holds the information used to identify a node

type Node

type Node struct {
	Attributes Attributes
	Gid        Nid
	Name       string
}

A node in the object graph

func (*Node) Is

func (n *Node) Is(other interface{}) bool

func (*Node) Rel

func (n *Node) Rel(object string, predicate *Node) *Relation

type Predicate

type Predicate func(*Relation) bool

Used to describe if a Relation have some attribute, when nil always returns true

func (Predicate) Valid

func (p Predicate) Valid(r *Relation) bool

type Query

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

A query used to walk the graph

type Relation

type Relation struct {
	From       *Node
	To         *Node
	Name       string
	Attributes Attributes
}

A connection between two nodes

type RelationSet

type RelationSet []*Relation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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