API for borneo.core - borneo ()


Usage:
(ns your-namespace
  (:require borneo.core))

Overview

Clojure wrapper for Neo4j, a graph database.

See project page (http://github.com/wagjo/borneo) for usage instructions,
documentation and examples.

Notes:
- Using official Neo4j bindings.
- Not using Blueprints interface.
- neo-db holds the current db instance, so that users do not have
  to supply db instance at each call to db operations. This approach has
  of course some drawbacks , but I've found it suitable for my purposes.
- All mutable functions are by default wrapped in transactions. That
  means you don't have to explicitly put them in transactions. The Neo4j
  transaction model allows for fast transaction nesting, so you can easily
  have your own transaction if you have a group of mutable functions.
  In that case just wrap your functions inside with-tx.
- NullPointerException is thrown if there is no open connection to the db.

Public Variables and Functions



*neo-db*

var

  
Holds the current database instance.
Source


ReturnableEvaluator

var

  
Protocol for return evaluation. Used for graph traversing.
Functions:
(returnable-node? [this pos]) - Should return true if node should
                                be returned. pos will be current
                                position map.
Source


StopEvaluator

var

  
Protocol for stop evaluation. Used for graph traversing.
Functions:
(stop-node? [this pos]) - Should return true if at stop node.
                          pos will be current position map.
Source


all-nodes

function
Usage: (all-nodes)
Returns lazy-seq of all nodes in the db.
Source


all-rel-types

function
Usage: (all-rel-types)
Returns lazy seq of all relationship types currently in database.
Source


create-child!

function
Usage: (create-child! type props)
       (create-child! node type props)
Creates a node that is a child of the specified parent node
(or root node) along the specified relationship.
props is a map that defines the properties of the node.
This is a convenience function.
Source


create-node!

function
Usage: (create-node!)
       (create-node! props)
Creates a new node, not linked with any other nodes.
Source


create-rel!

function
Usage: (create-rel! from type to)
Creates relationship of a supplied type between from and to nodes.
Source


delete!

function
Usage: (delete! item)
Deletes node or relationship.
Only node which has no relationships attached to it can be deleted.
Source


delete-node!

function
Usage: (delete-node! node)
Delete node and all its relationships.
This is a convenience function.
Source


end-node

function
Usage: (end-node r)
Returns end node for given relationship.
Source


get-id

function
Usage: (get-id item)
Returns id for a given node or relationship.
Note that ids are not very good as unique identifiers.
Source


get-path

function
Usage: (get-path)
Returns path to where the database is stored.
Source


index

function
Usage: (index)
Returns the IndexManager paired with this graph database service.
Source


node-by-id

function
Usage: (node-by-id id)
Returns node with a given id.
Note that ids are not very good as unique identifiers.
Source


other-node

function
Usage: (other-node r node)
Returns other node for given relationship.
This is a convenience function.
Source


prop

function
Usage: (prop c k)
Returns property value based on its key.
If property is not found, returns nil.
If property value is string which starts with colon,
it is converted to keyword.
Source


prop?

function
Usage: (prop? c k)
Returns true if given node or relationship contains
property with a given key.
Source


props

function
Usage: (props c)
Returns map of properties for a given node or relationship.
Fetches all properties and can be very resource consuming if node
contains many large properties. This is a convenience function.
If property value is string which starts with colon,
is is converted to keyword.
Source


purge!

function
Usage: (purge!)
Deletes all nodes from database together with all relationships.
Source


read-only?

function
Usage: (read-only?)
Returns true if database is read only.
Source


rel-by-id

function
Usage: (rel-by-id id)
Returns relationship with a given id.
Note that ids are not very good as unique identifiers.
Source


rel-nodes

function
Usage: (rel-nodes r)
Returns the two nodes attached to the given relationship.
This is a convenience function.
Source


rel-type

function
Usage: (rel-type r)
Returns type of given relationship.
Source


rel?

function
Usage: (rel? node)
       (rel? node type-or-types)
       (rel? node type direction)
Returns true if there are relationships attached to this node. Syntax:
[node]                - All relationships.
[node type-or-types]  - Relationships of any of specified types with
                        any direction.
[node type direction] - Relationships of specified type and
                        of specified direction. You can supply nil for
                        one of the arguments if you do not care for
                        either direction of relationship type.
Valid directions are :in :out and :both, parameter type can be any keyword.
Examples: (rel? node)                  ; All rels
          (rel? node :foo)             ; Rels of :foo type of any direction
          (rel? node [:foo :bar :baz]) ; Rels of any of specified types,
                                       ; any directions
          (rel? node :foo :in)         ; Rels of :foo type, :in direction
          (rel? node nil :in)          ; Rels of any type of :in direction
          (rel? node :foo nil)         ; Use (rel? node :foo) instead
Source


rels

function
Usage: (rels node)
       (rels node type-or-types)
       (rels node type direction)
Returns relationships attached to this node. Syntax:
[node]                - All relationships.
[node type-or-types]  - Relationships of any of specified types with
                        any direction.
[node type direction] - Relationships of specified type and
                        of specified direction. You can supply nil for
                        one of the arguments if you do not care for
                        either direction of relationship type.
Valid directions are :in :out and :both, parameter type can be any keyword.
Examples: (rels node)                  ; All rels
          (rels node :foo)             ; Rels of :foo type of any direction
          (rels node [:foo :bar :baz]) ; Rels of any of specified types,
                                       ; any directions
          (rels node :foo :in)         ; Rels of :foo type, :in direction
          (rels node nil :in)          ; Rels of any type of :in direction
          (rels node :foo nil)         ; Use (rel node :foo) instead
Source


root

function
Usage: (root)
Returns reference/root node.
Source


set-prop!

function
Usage: (set-prop! c key)
       (set-prop! c key value)
Sets or remove property for a given node or relationship.
The property value must be one of the valid property types 
(see Neo4j docs) or a keyword.
If a property value is nil, removes this property from the given
node or relationship.
Source


set-props!

function
Usage: (set-props! c props)
Sets properties for a given node or relationship.
The property value must be one of the valid property types 
(see Neo4j docs) or a keyword.
If a property value is nil, removes this property from the given
node or relationship. This is a convenience function.
Source


single-rel

function
Usage: (single-rel node type)
       (single-rel node type direction)
Returns the only relationship for the node of the given type and
direction.
Valid directions are :in :out and :both, defaults to :out.
Source


start!

function
Usage: (start! path)
Establish a connection to the database.
Uses *neo-db* Var to hold the connection.
Do not use this function, use with-db! or with-local-db! instead.
Source


start-node

function
Usage: (start-node r)
Returns start node for given relationship.
Source


stop!

function
Usage: (stop!)
Closes a connection stored in *neo-db*.
Do not use this function, use with-db! or with-local-db! instead.
Source


traverse

function
Usage: (traverse node rel)
       (traverse node return-eval rel)
       (traverse node stop-eval return-eval rel)
       (traverse node order stop-eval return-eval rel)
Traverses the graph. Starting at the given node, traverse the graph
in specified order, stopping based on stop-eval. The return-eval
decides which nodes make it into the result. The rel is used to
decide which edges to traverse.
order - :breadth, :depth. Will be :depth if nil supplied.
stop-eval accepts following values:
  - :end or nil - End of graph.
  - :1, :2, :X (X being any positive integer) - Depth of X.
  - Custom function which takes one argument, current position
    and should return true when at stop node.
return-eval accepts following values:
  - :all-but-start or nil  - all but start nodes.
  - :all - all nodes.
  - Custom function which takes one argument, current position map
    and should return true when node at current position should be returned.
  - Map defining key-value pairs that will be matched against
    properties of wanna-be returned nodes.
rel - Keyword representing relation type or a map where keys are
      relation type keywords and values are directions (:in or :out).
Source


walk

function
Usage: (walk node & types)
Walks through the graph by following specified relations. Returns last node.
Throws NullPointerException if path is wrong.
Throws NotFoundException if path is ambiguous.
Source


with-db!

macro
Usage: (with-db! path & body)
Establish a connection to the neo db.
Because there is an overhead when establishing connection, users should
not call this macro often. Also note that this macro is not threadsafe.
Source


with-local-db!

macro
Usage: (with-local-db! path & body)
Establish a connection to the neo db. Connection is visible
only in current thread. Because there is an overhead when
establishing connection, users should not call this macro often.
This is a treadsafe version, which limits connection to
the current thread only. This allows you to have parallel
connections to different databases. It is not recommended to use
this function together with with-db! in one program.
Source


with-tx

macro
Usage: (with-tx & body)
Establish a transaction. Use it for mutable db operations.
If you do not want to commit it, throw an exception.
All mutable functions use transactions by default, so you don't
have to use this macro. You should use this macro to group your
functions into a bigger transactions.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.