Skip to content

Commit

Permalink
Merge pull request #56 from garrettheaver/master
Browse files Browse the repository at this point in the history
batch remove_relationship_from_index
  • Loading branch information
maxdemarzi committed Aug 27, 2012
2 parents b227119 + 6bfaef8 commit 9758878
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ def get_batch(args)
when 4 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{get_id(args[3])}" }
when 3 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{get_id(args[2])}" }
end
when :remove_relationship_from_index
case args.size
when 5 then {:method => "DELETE", :to => "/index/relationship/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" }
when 4 then {:method => "DELETE", :to => "/index/relationship/#{args[1]}/#{args[2]}/#{get_id(args[3])}" }
when 3 then {:method => "DELETE", :to => "/index/relationship/#{args[1]}/#{get_id(args[2])}" }
end
when :delete_node
{:method => "DELETE", :to => "/node/#{get_id(args[1])}"}
else
Expand Down
18 changes: 18 additions & 0 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,24 @@
@neo.get_node_index(index, key, value3).should be_nil
end

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

node1 = @neo.create_node
node2 = @neo.create_node
relationship1 = @neo.create_unique_relationship(index, key, value1, "friends", node1, node2)
relationship2 = @neo.create_unique_relationship(index, key, value2, "friends", node2, node1)

batch_result = @neo.batch [:remove_relationship_from_index, index, key, relationship1],
[:remove_relationship_from_index, index, key, relationship2]

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

end

describe "referenced batch" do
Expand Down

0 comments on commit 9758878

Please sign in to comment.