diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 73781a3..0f3695f 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -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 @@ -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])}")