From 6bfaef81d066ce4cfac8c138481f604e94e14076 Mon Sep 17 00:00:00 2001 From: Garrett Heaver Date: Mon, 27 Aug 2012 17:18:16 +0100 Subject: [PATCH] adding remove_relationship_from_index as batch operation --- lib/neography/rest.rb | 6 ++++++ spec/integration/rest_batch_spec.rb | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 5a3bac0..03c0fd2 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -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 diff --git a/spec/integration/rest_batch_spec.rb b/spec/integration/rest_batch_spec.rb index 692c7f9..b674050 100644 --- a/spec/integration/rest_batch_spec.rb +++ b/spec/integration/rest_batch_spec.rb @@ -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