Permalink
Browse files

batch arrays of arrays

  • Loading branch information...
maxdemarzi committed Jan 7, 2012
1 parent 1e37b32 commit eb03523695ff30693faa7a153adf0bba54c91296
Showing with 14 additions and 4 deletions.
  1. +7 −4 README.rdoc
  2. +7 −0 spec/integration/rest_batch_spec.rb
View
@@ -172,18 +172,21 @@ Batch (in progress):
@neo.batch [:get_relationship, rel1],
[:get_relationship, rel2] # Gets two relationships in a batch
@neo.batch [:create_relationship, "friends",
node1, node2, {:since => "high school"}]
node1, node2, {:since => "high school"}],
[:create_relationship, "friends",
node1, node3, {:since => "college"}] # Creates two relationships in a batch
@neo.batch [:create_node, {"name" => "Max"}],
[:create_node, {"name" => "Marc"}], # Creates two nodes and index them
[:add_node_to_index, "test_node_index", key, value, "{0}"]
[:add_node_to_index, "test_node_index", key, value, "{1}"]
[:add_node_to_index, "test_node_index", key, value, "{0}"],
[:add_node_to_index, "test_node_index", key, value, "{1}"],
[:create_relationship, "friends", # and create a relationship for those
"{0}", "{1}", {:since => "college"}] # newly created nodes
"{0}", "{1}", {:since => "college"}], # newly created nodes
[:add_relationship_to_index,
"test_relationship_index", key, value, "{4}"] # and index the new relationship
@neo.batch *[[:create_node, {"name" => "Max"}],
[:create_node, {"name" => "Marc"}]] # Use the Splat (*) with Arrays of Arrays
See http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html for Neo4j Batch operations documentation.
Experimental:
@@ -47,6 +47,13 @@
batch_result.last["body"]["data"]["name"].should == "Marc"
end
it "can create multiple nodes given an *array" do
batch_result = @neo.batch *[[:create_node, {"name" => "Max"}], [:create_node, {"name" => "Marc"}]]
batch_result.first["body"]["data"]["name"].should == "Max"
batch_result.last["body"]["data"]["name"].should == "Marc"
end
it "can update a property of a node" do
new_node = @neo.create_node("name" => "Max")
batch_result = @neo.batch [:set_node_property, new_node, {"name" => "Marc"}]

0 comments on commit eb03523

Please sign in to comment.