Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple wrapper around Neo4J
Clojure
branch: master

This branch is 8 commits ahead, 1 commit behind scusack:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/neo4j_clj
test/neo4j_clj/test
.gitignore
README.md
project.clj

README.md

neo4j-clj

A clojure library that provides a more clojuresque way of interacting with the Neo4j.

Tests against Neo4j EmbeddedGraphDatabase and RestGraphDatabase from https://github.com/neo4j/java-rest-binding.

Usage

(def db (make-embedded-db "/tmp/neo4j"))

;; or (def db (RestGraphDatabase. "http://localhost:7474/db/data"))

(def n1 (with-transaction* db (create-node)))
(def n2 (with-transaction* db (create-node)))

(with-transaction* db (associate n1 :name "name"))
=> #<NodeProxy Node[1]>

(property n1 :name)
=> "name"

(property n1 "name")
=> "name"

(with-transaction* db (associate n1 :value "value"))
=> #<NodeProxy Node[1]>

(properties n1)
=> {:value "value", :name "name"}

(with-transaction* db (disassociate n1 [:value]))
=> #<NodeProxy Node[1]>

(properties n1)
=> {:name "name"}

(def r1 (with-transaction* db (relate n1 n2 :knows {:1 "one"
                                                    :2 "two"
                                                    :3 3})))
(properties r1)
=> {:2 "two", :3 3, :1 "one"}

(follow n1 :knows)
=> #<NodeProxy Node[2]>

(def r (with-transaction* db (cypher-query "start n=node(0) where 1=1 return n")))

(cypher-result-as-rows  r)
=> ((#<NodeProxy Node[0]>))

(cypher-result-as-nodes  r)
=> (#<NodeProxy Node[0]>)

(.shutdown db)

Testing

In order to run the tests you need to add the plugin available from https://github.com/jexp/neo4j-clean-remote-db-addon.

Installation

neo4j-clj is available as a Maven artifact from Clojars:

[neo4j-clj "0.0.2-SNAPSHOT"]

License

Released under the MIT License: http://www.opensource.org/licenses/mit-license.php

Something went wrong with that request. Please try again.