diff --git a/README.rdoc b/README.rdoc index d4c4542..2c76d93 100644 --- a/README.rdoc +++ b/README.rdoc @@ -6,7 +6,9 @@ Neography is a thin Ruby wrapper to the Neo4j Rest API, for more information: If you want to the full power of Neo4j, you will want to use JRuby and the excellent Neo4j.rb gem at https://github.com/andreasronge/neo4j by Andreas Ronge -A complement to Neography is the Neology Gem at https://github.com/lordkada/neology by Carlo Alberto Degli Atti +Complement to Neography are the: +Neology Gem at https://github.com/lordkada/neology by Carlo Alberto Degli Atti +Neoid Gem at https://github.com/elado/neoid by Elad Ossadon An alternative is the Architect4r Gem at https://github.com/namxam/architect4r by Maximilian Schulz @@ -96,8 +98,11 @@ To Use: @neo = Neography::Rest.new # Inialize using all default parameters @neo.get_root # Get the root node - node1 = @neo.create_node # Create an empty node - node2 = @neo.create_node("age" => 31, "name" => "Max") # Create a node with some properties + @neo.create_node # Create an empty node + @neo.create_node("age" => 31, "name" => "Max") # Create a node with some properties + @neo.create_unique_node(index_name, key, unique_value, # Create a unique node + {"age" => 31, "name" => "Max"}) # this needs an existing index + @neo.get_node(node2) # Get a node and its properties @neo.delete_node(node2) # Delete an unrelated node @neo.delete_node!(node2) # Delete a node and all its relationships @@ -110,8 +115,11 @@ To Use: @neo.remove_node_properties(node1, "weight") # Remove one property of a node @neo.remove_node_properties(node1, ["weight","age"]) # Remove multiple properties of a node - rel1 = @neo.create_relationship("friends", node1, node2) # Create a relationship between node1 and node2 - rel2 = @neo.get_relationship(rel1) # Get a relationship + @neo.create_relationship("friends", node1, node2) # Create a relationship between node1 and node2 + @neo.create_unique_relationship(index_name, key, value, # Create a unique relationship between nodes + "friends", new_node1, new_node2) # this needs an existing index + + @neo.get_relationship(rel1) # Get a relationship @neo.get_node_relationships(node1) # Get all relationships @neo.get_node_relationships(node1, "in") # Get only incoming relationships @neo.get_node_relationships(node1, "all", "enemies") # Get all relationships of type enemies @@ -169,10 +177,6 @@ To Use: # "depth" is a short-hand way of specifying a prune evaluator which prunes after a certain depth. # If not specified a depth of 1 is used and if a "prune evaluator" is specified instead of a depth, no depth limit is set. -Please see the specs for more examples. - -Batch (in progress): - @neo.batch [:get_node, node1], [:get_node, node2] # Gets two nodes in a batch @neo.batch [:create_node, {"name" => "Max"}], [:create_node, {"name" => "Marc"}] # Creates two nodes in a batch @@ -198,6 +202,10 @@ Batch (in progress): See http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html for Neo4j Batch operations documentation. + +Please see the specs for more examples. + + Experimental: nodes = @neo.create_nodes(5) # Create 5 empty nodes diff --git a/spec/integration/rest_node_spec.rb b/spec/integration/rest_node_spec.rb index a338ba3..417ca92 100644 --- a/spec/integration/rest_node_spec.rb +++ b/spec/integration/rest_node_spec.rb @@ -36,6 +36,17 @@ new_node["data"]["name"].should == "Max" new_node["data"]["age"].should == 31 end + + it "can create a unique node with more than one property" do + index_name = generate_text(6) + key = generate_text(6) + value = generate_text + @neo.create_node_index(index_name) + new_node = @neo.create_unique_node(index_name, key, value, {"age" => 31, "name" => "Max"}) + new_node["data"]["name"].should == "Max" + new_node["data"]["age"].should == 31 + end + end describe "get_node" do diff --git a/spec/integration/rest_relationship_spec.rb b/spec/integration/rest_relationship_spec.rb index 281b60c..1609c9d 100644 --- a/spec/integration/rest_relationship_spec.rb +++ b/spec/integration/rest_relationship_spec.rb @@ -30,6 +30,28 @@ new_relationship["data"]["since"].should == '10-1-2010' new_relationship["data"]["met"].should == "college" end + + it "can create a unique node with more than one property" do + index_name = generate_text(6) + key = generate_text(6) + value = generate_text + @neo.create_node_index(index_name) + new_node = @neo.create_unique_node(index_name, key, value, {"age" => 31, "name" => "Max"}) + new_node["data"]["name"].should == "Max" + new_node["data"]["age"].should == 31 + end + + it "can create a unique relationship" do + index_name = generate_text(6) + key = generate_text(6) + value = generate_text + new_node1 = @neo.create_node + new_node2 = @neo.create_node + new_relationship = @neo.create_unique_relationship(index_name, key, value, "friends", new_node1, new_node2) + new_relationship["data"][key].should == value + end + + end describe "get_relationship" do