Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :remove_node_property to batch operations #146

Merged
merged 1 commit into from
Feb 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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