Skip to content

Commit

Permalink
Merge pull request #47 from samirahmed/master
Browse files Browse the repository at this point in the history
Added 2 more batch operations
  • Loading branch information
maxdemarzi committed Jun 20, 2012
2 parents 7eec488 + a2bdf97 commit e048609
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@ def get_batch(args)
else
{:method => "POST", :to => @cypher_path, :body => {:query => args[1]}}
end
else
when :remove_node_from_index
{:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" }
when :delete_node
{:method => "DELETE", :to => "/node/#{get_id(args[1])}"}
else
raise "Unknown option #{args[0]}"
end
end
Expand Down
28 changes: 27 additions & 1 deletion spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,32 @@
batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == id
end

it "can delete a node in batch" do

node1 = @neo.create_node
node2 = @neo.create_node
id1 = node1['self'].split('/').last
id2 = node2['self'].split('/').last
batch_result = @neo.batch [:delete_node, id1 ], [:delete_node, id2]
@neo.get_node(node1).should be_nil
@neo.get_node(node2).should be_nil

end

it "can remove a node from an index in batch " do
index = generate_text(6)
key = generate_text(6)
value1 = generate_text
value2 = generate_text

node1 = @neo.create_unique_node( index , key , value1 , { "name" => "Max" } )
node2 = @neo.create_unique_node( index , key , value2 , { "name" => "Neo" })

batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ], [:remove_node_from_index, index, key, value2, node2 ]

@neo.get_node_index(index, key, value1).should be_nil
@neo.get_node_index(index, key, value2).should be_nil
end

end

Expand Down Expand Up @@ -385,4 +411,4 @@

end

end
end

0 comments on commit e048609

Please sign in to comment.