Skip to content

Commit

Permalink
added 2 more functions - create_unique_node and create_unique_realtio…
Browse files Browse the repository at this point in the history
…nship
  • Loading branch information
ajay authored and maxdemarzi committed Feb 9, 2012
1 parent 485e77f commit 914d4d3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ def create_relationship(type, from, to, props = nil)
post("/node/#{get_id(from)}/relationships", options)
end

def create_unique_relationship(index, key, value, type, from, to)
body = {:key=>key,:value=>value, :type => type }
body[:start] = self.configuration + "/node/#{get_id(from)}"
body[:end] = self.configuration + "/node/#{get_id(to)}"
options = { :body => body.to_json, :headers => {'Content-Type' => 'application/json'} }
post("/index/relationship/#{index}?unique", options)
end

def get_relationship(id)
get("/relationship/#{get_id(id)}")
end
Expand Down Expand Up @@ -256,6 +264,11 @@ def add_node_to_index(index, key, value, id)
post("/index/node/#{index}", options)
end

def create_unique_node(index, key, value, props={})
options = { :body => ({:properties=>props, :key => key, :value => value }).to_json, :headers => {'Content-Type' => 'application/json'} }
post("/index/node/#{index}?unique", options)
end

def remove_node_from_index(*args)
case args.size
when 4 then delete("/index/node/#{args[0]}/#{args[1]}/#{args[2]}/#{get_id(args[3])}")
Expand Down

0 comments on commit 914d4d3

Please sign in to comment.