Skip to content

Commit

Permalink
Add delete_relationship to batch operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
pete committed Jul 30, 2012
1 parent 802802c commit bbb420a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ def get_batch(args)
{:method => "POST", :to => (args[2].is_a?(String) && args[2].start_with?("{") ? "" : "/node/") + "#{get_id(args[2])}/relationships", :body => {:to => (args[3].is_a?(String) && args[3].start_with?("{") ? "" : "/node/") + "#{get_id(args[3])}", :type => args[1], :data => args[4] } }
when :create_unique_relationship
{:method => "POST", :to => "/index/relationship/#{args[1]}?unique", :body => {:key => args[2], :value => args[3], :type => args[4], :start => (args[5].is_a?(String) && args[5].start_with?("{") ? "" : "/node/") + "#{get_id(args[5])}", :end=> (args[6].is_a?(String) && args[6].start_with?("{") ? "" : "/node/") + "#{get_id(args[6])}"} }
when :delete_relationship
{:method => "DELETE", :to => "/relationship/#{get_id(args[1])}"}
when :set_relationship_property
{:method => "PUT", :to => "/relationship/#{get_id(args[1])}/properties/#{args[2].keys.first}", :body => args[2].values.first}
when :reset_relationship_properties
Expand Down
12 changes: 12 additions & 0 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@
batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
end

it "can delete a single relationship" do
node1 = @neo.create_node
node2 = @neo.create_node
batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "time immemorial"}]
batch_result.should_not be_nil
batch_result[0]["status"].should == 201
id = batch_result.first["body"]["self"].split("/").last
batch_result = @neo.batch [:delete_relationship, id]
batch_result[0]["status"].should == 204
batch_result[0]["from"].should == "/relationship/#{id}"
end

it "can create a unique relationship" do
index_name = generate_text(6)
key = generate_text(6)
Expand Down

0 comments on commit bbb420a

Please sign in to comment.