Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

private var fix, wrap rels in seq

  • Loading branch information...
commit 146ea48c25b4c7766eae9dd6d4552bf47bc2a327 1 parent 92fe75b
@wagjo wagjo authored
Showing with 14 additions and 12 deletions.
  1. +1 −0  README.md
  2. +13 −12 src/borneo/core.clj
View
1  README.md
@@ -29,6 +29,7 @@ emphasized):
* _[index](http://wagjo.github.com/borneo/borneo.core-api.html#borneo.core/index)_ - returns Index Manager
* _Property Containers (both Nodes and Relationships)_
* _[prop?](http://wagjo.github.com/borneo/borneo.core-api.html#borneo.core/prop?)_ - returns true if node or relationship contains given property
+ * _[prop](http://wagjo.github.com/borneo/borneo.core-api.html#borneo.core/prop)_ - returns specific property value for a given node or relationship
* ___[props](http://wagjo.github.com/borneo/borneo.core-api.html#borneo.core/props)_ - returns map of properties for a given node or relationship__
* _[set-prop!](http://wagjo.github.com/borneo/borneo.core-api.html#borneo.core/set-prop!)_ - sets or removes property in a given node or relationship
* ___[set-props!](http://wagjo.github.com/borneo/borneo.core-api.html#borneo.core/set-props!)_ - sets (or removes) properties for a given node or relationships__
View
25 src/borneo/core.clj
@@ -221,23 +221,24 @@
(= :all e) org.neo4j.graphdb.ReturnableEvaluator/ALL
:else (returnable-with-protocol e)))
-(defn- start!
+;;;; Public API
+
+(defn start!
"Establish a connection to the database.
- Uses *neo-db* Var to hold the connection."
+ Uses *neo-db* Var to hold the connection.
+ Do not use this function, use with-db! or with-local-db! instead"
[path]
(io!)
(let [n (EmbeddedGraphDatabase. path)]
(alter-var-root #'*neo-db* (fn [_] n))))
-(defn- stop!
- "Closes a connection stored in *neo-db*"
+(defn stop!
+ "Closes a connection stored in *neo-db*.
+ Do not use this function, use with-db! or with-local-db! instead"
[]
(io!)
(.shutdown *neo-db*))
-
-;;;; Public API
-
(defmacro with-db!
"Establish a connection to the neo db.
Because there is an overhead when establishing connection, users should
@@ -247,7 +248,7 @@
`(do
;; Not using binding macro, because db should be accessible
;; from multiple threads.
- (start! path)
+ (start! ~path)
(try
~@body
(finally (stop!)))))
@@ -475,16 +476,16 @@
(rels node nil :in) ; Rels of any type of :in direction
(rels node :foo nil) ; Use (rel node :foo) instead"
([^Node node]
- (.getRelationships node))
+ (seq (.getRelationships node)))
([^Node node type-or-types]
(let [t (map rel-type* (flatten [type-or-types]))]
;; TODO: Is there a way to type hint array in following call?
- (.getRelationships node (into-array RelationshipType t))))
+ (seq (.getRelationships node (into-array RelationshipType t)))))
([^Node node type direction]
(cond
- (nil? type) (.getRelationships node (rel-dir direction))
+ (nil? type) (seq (.getRelationships node (rel-dir direction)))
(nil? direction) (rels node type)
- :else (.getRelationships node (rel-type* type) (rel-dir direction)))))
+ :else (seq (.getRelationships node (rel-type* type) (rel-dir direction))))))
(defn single-rel
"Returns the only relationship for the node of the given type and
Please sign in to comment.
Something went wrong with that request. Please try again.