Skip to content

Commit

Permalink
Merge pull request #162 from pwaleczek/master
Browse files Browse the repository at this point in the history
Added 'Create or Fail' methods to node/relationship indexes
maxdemarzi committed Apr 14, 2014

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 6829cfd + aab503a commit 350684c
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions lib/neography/rest/node_indexes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Neography
class Rest
module NodeIndexes
module NodeIndexes
include Neography::Rest::Helpers

def list_node_indexes
@@ -117,7 +117,21 @@ def get_or_create_unique_node(index, key, value, properties = {})
:headers => json_content_type
}
@connection.post("/index/node/%{index}?uniqueness=%{function}" % {:index => index, :function => 'get_or_create'}, options)


end

def create_or_fail_unique_node(index, key, value, properties = {})
options = {
:body => (
{ :properties => properties,
:key => key,
:value => value
}
).to_json,
:headers => json_content_type
}
@connection.post("/index/node/%{index}?uniqueness=%{function}" % {:index => index, :function => 'create_or_fail'}, options)

end

end
18 changes: 16 additions & 2 deletions lib/neography/rest/relationship_indexes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Neography
class Rest
module RelationshipIndexes
module RelationshipIndexes
include Neography::Rest::Helpers

def list_relationship_indexes
@@ -118,7 +118,21 @@ def get_or_create_unique_relationship(index, key, value, properties = {})
:headers => json_content_type
}
@connection.post("/index/relationship/%{index}?uniqueness=%{function}" % {:index => index, :function => 'get_or_create'}, options)


end

def create_or_fail_unique_relationship(index, key, value, properties = {})
options = {
:body => (
{ :properties => properties,
:key => key,
:value => value
}
).to_json,
:headers => json_content_type
}
@connection.post("/index/relationship/%{index}?uniqueness=%{function}" % {:index => index, :function => 'create_or_fail'}, options)

end

end

0 comments on commit 350684c

Please sign in to comment.