Liking cljdoc? Tell your friends :D

borneo.core

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.
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.
raw docstring

*exec-eng*clj

Holds an execution engine around the graph database to use for Cypher queries.

Holds an execution engine around the graph database to use for Cypher queries.
sourceraw docstring

*neo-db*clj

Holds the current database instance.

Holds the current database instance.
sourceraw docstring

add-label!clj

(add-label! node name)

Adds the given label to the node.

Adds the given label to the node.
sourceraw docstring

all-nodesclj

(all-nodes)

Returns lazy-seq of all nodes in the db.

Returns lazy-seq of all nodes in the db.
sourceraw docstring

all-nodes-with-labelclj

(all-nodes-with-label label-name)

Returns lazy-seq of all nodes with the given label.

Returns lazy-seq of all nodes with the given label.
sourceraw docstring

all-rel-typesclj

(all-rel-types)

Returns lazy seq of all relationship types currently in database.

Returns lazy seq of all relationship types currently in database.
sourceraw docstring

create-child!clj

(create-child! node type props)

Creates a node that is a child of the specified parent node along the specified relationship. props is a map that defines the properties of the node. This is a convenience function.

Creates a node that is a child of the specified parent node
along the specified relationship.
props is a map that defines the properties of the node.
This is a convenience function.
sourceraw docstring

create-labeled-node!clj

(create-labeled-node! & label-names)
source

create-node!clj

(create-node!)
(create-node! props & label-names)

Creates a new node, not linked with any other nodes. Labels can optionally be provided to add to the node.

Creates a new node, not linked with any other nodes.
Labels can optionally be provided to add to the node.
sourceraw docstring

create-rel!clj

(create-rel! from type to)

Creates relationship of a supplied type between from and to nodes.

Creates relationship of a supplied type between from and to nodes.
sourceraw docstring

cypherclj

(cypher query)
(cypher query params)

Returns lazy-seq of results from a Cypher query

Returns lazy-seq of results from a Cypher query
sourceraw docstring

delete!clj

(delete! item)

Deletes node or relationship. Only node which has no relationships attached to it can be deleted.

Deletes node or relationship.
Only node which has no relationships attached to it can be deleted.
sourceraw docstring

delete-node!clj

(delete-node! node)

Delete node and all its relationships. This is a convenience function.

Delete node and all its relationships.
This is a convenience function.
sourceraw docstring

dynamic-labelclj

(dynamic-label name)

Creates a label with the supplied name

Creates a label with the supplied name
sourceraw docstring

end-nodeclj

(end-node r)

Returns end node for given relationship.

Returns end node for given relationship.
sourceraw docstring

find-nodesclj

(find-nodes label-name key val)

Finds nodes with the supplied label and predicate

Finds nodes with the supplied label and predicate
sourceraw docstring

get-idclj

(get-id item)

Returns id for a given node or relationship. Note that ids are not very good as unique identifiers.

Returns id for a given node or relationship.
Note that ids are not very good as unique identifiers.
sourceraw docstring

get-pathclj

(get-path)

Returns path to where the database is stored.

Returns path to where the database is stored.
sourceraw docstring

indexclj

(index)

Returns the IndexManager paired with this graph database service.

Returns the IndexManager paired with this graph database service.
sourceraw docstring

label?clj

(label? node label-name)

Returns true if the given node has a label with the supplied name

Returns true if the given node
has a label with the supplied name
sourceraw docstring

labelsclj

(labels node)

Lists all labels attached to this node.

Lists all labels attached to this node.
sourceraw docstring

node-by-idclj

(node-by-id id)

Returns node with a given id, or nil if no such node exists. Note that ids are not very good as unique identifiers.

Returns node with a given id, or nil if no such node exists.
Note that ids are not very good as unique identifiers.
sourceraw docstring

other-nodeclj

(other-node r node)

Returns other node for given relationship. This is a convenience function.

Returns other node for given relationship.
This is a convenience function.
sourceraw docstring

propclj

(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.

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.
sourceraw docstring

prop?clj

(prop? c k)

Returns true if given node or relationship contains property with a given key.

Returns true if given node or relationship contains
property with a given key.
sourceraw docstring

propsclj

(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.

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.
sourceraw docstring

purge!clj

(purge!)

Deletes all nodes from database together with all relationships.

Deletes all nodes from database together with all relationships.
sourceraw docstring

read-only?clj

(read-only?)

Returns true if database is read only.

Returns true if database is read only.
sourceraw docstring

rel-by-idclj

(rel-by-id id)

Returns relationship with a given id, or nil if no such relationship exists. Note that ids are not very good as unique identifiers.

Returns relationship with a given id, or nil if no such relationship exists.
Note that ids are not very good as unique identifiers.
sourceraw docstring

rel-nodesclj

(rel-nodes r)

Returns the two nodes attached to the given relationship. This is a convenience function.

Returns the two nodes attached to the given relationship.
This is a convenience function.
sourceraw docstring

rel-typeclj

(rel-type r)

Returns type of given relationship.

Returns type of given relationship.
sourceraw docstring

rel?clj

(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

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
sourceraw docstring

relsclj

(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

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
sourceraw docstring

remove-label!clj

(remove-label! node name)

Removes the supplied label from the node.

Removes the supplied label from the node.
sourceraw docstring

ReturnableEvaluatorcljprotocol

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.

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.

returnable-node?clj

(returnable-node? this pos)
sourceraw docstring

set-prop!clj

(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.

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.
sourceraw docstring

set-props!clj

(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.

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.
sourceraw docstring

single-relclj

(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.

Returns the only relationship for the node of the given type and
direction.
Valid directions are :in :out and :both, defaults to :out.
sourceraw docstring

start!clj

(start! path)

Establish a connection to the database. Uses neo-db Var to hold the connection. Uses exec-eng Var to reuse for Cypher queries. Do not use this function, use with-db! or with-local-db! instead.

Establish a connection to the database.
Uses *neo-db* Var to hold the connection.
Uses *exec-eng* Var to reuse for Cypher queries.
Do not use this function, use with-db! or with-local-db! instead.
sourceraw docstring

start-nodeclj

(start-node r)

Returns start node for given relationship.

Returns start node for given relationship.
sourceraw docstring

stop!clj

(stop!)

Closes a connection stored in neo-db. Do not use this function, use with-db! or with-local-db! instead.

Closes a connection stored in *neo-db*.
Do not use this function, use with-db! or with-local-db! instead.
sourceraw docstring

StopEvaluatorcljprotocol

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.

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.

stop-node?clj

(stop-node? this pos)
sourceraw docstring

traverseclj

(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).
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).
sourceraw docstring

walkclj

(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.

Walks through the graph by following specified relations. Returns last node.
Throws NullPointerException if path is wrong.
Throws NotFoundException if path is ambiguous.
sourceraw docstring

with-db!cljmacro

(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.

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.
sourceraw docstring

with-local-db!cljmacro

(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.

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.
sourceraw docstring

with-txcljmacro

(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.

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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close