Skip to content

Commit

Permalink
Merge pull request #146 from continuum/batch-remove-node-property
Browse files Browse the repository at this point in the history
Add :remove_node_property to batch operations
  • Loading branch information
maxdemarzi committed Feb 13, 2014
2 parents 715ef13 + 4177e6a commit 17eb07e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/neography/rest/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def reset_node_properties(id, body)
end
end

def remove_node_property(id, property)
delete NodeProperties.single_path(:id => get_id(id), :property => property)
end

# NodeLabel

def add_label(id, body)
Expand Down
26 changes: 26 additions & 0 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,32 @@
existing_node["data"]["weight"].should be_nil
end

it "can remove a property of a node" do
new_node = @neo.create_node("name" => "Max", "weight" => 200)
batch_result = @neo.batch [:remove_node_property, new_node, "weight"]
batch_result.first.should have_key("id")
batch_result.first.should have_key("from")
existing_node = @neo.get_node(new_node)
existing_node["data"]["name"].should == "Max"
existing_node["data"]["weight"].should be_nil
end

it "can remove a property of multiple nodes" do
node1 = @neo.create_node("name" => "Max", "weight" => 200)
node2 = @neo.create_node("name" => "Marc", "weight" => 180)
batch_result = @neo.batch [:remove_node_property, node1, "name"], [:remove_node_property, node2, "name"]
batch_result.first.should have_key("id")
batch_result.first.should have_key("from")
batch_result.last.should have_key("id")
batch_result.last.should have_key("from")
existing_node = @neo.get_node(node1)
existing_node["data"]["name"].should be_nil
existing_node["data"]["weight"].should == 200
existing_node = @neo.get_node(node2)
existing_node["data"]["name"].should be_nil
existing_node["data"]["weight"].should == 180
end

it "can get a single relationship" do
node1 = @neo.create_node
node2 = @neo.create_node
Expand Down

0 comments on commit 17eb07e

Please sign in to comment.