neo4j-http 1.0.2 → 1.0.3.then

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3526e27e1765f572d398e295580e875cb589f02ced49dbf4963a52342400eff7
4
- data.tar.gz: 693b3f5ede2c474f268c097298340ffa38ef8455e901b89406bf8af32ecc3aed
3
+ metadata.gz: 4c6361dc6d81de2e607be371cfdd59fa838152dc7ed68e560635801784e2b3ba
4
+ data.tar.gz: 6bc360768784964956d83a41f3f4e12ec4f8f8e028121f2b7541d1aa37acc723
5
5
  SHA512:
6
- metadata.gz: 985b031ef8f0c77cd9f8705d72c462f69c95f0fea00302dba11c15857aaa8f4a3515b29a4cf04b90d5970724304cb1179a357391621178e2287958b95d12a1f6
7
- data.tar.gz: 4e8e6dab0c4bcfc83fb897d6f3eb42b4abef3df63ff170ff3e78e1263045089f96c8e1c6b46bd7e9f5e969d5b35fbdc4801a282293235a00bcf774a4a76b1999
6
+ metadata.gz: 06a57ce8467c37b95db9752ba39e1e5535bca5e71edfdb858d5b62fc1516310260d365594b859399211061c446fc8a2d7cc5f4fee36085f29f0fbf2d44730630
7
+ data.tar.gz: 9205861cdcc7517bdd544cd89c34ce37f20d9243745c3938b56127686438a0aeb26a8a057117af25971a04a7c70dab4c957be0ba195880ed29f23e027bcb221f
@@ -4,8 +4,9 @@ module Neo4j
4
4
  module Http
5
5
  class Node < ObjectWrapper
6
6
  DEFAULT_PRIMARY_KEY_NAME = "uuid"
7
- def initialize(label:, graph_node_primary_key_name: DEFAULT_PRIMARY_KEY_NAME, **attributes)
7
+ def initialize(label:, primary_key_name: DEFAULT_PRIMARY_KEY_NAME, **attributes)
8
8
  super
9
+ @key_value = @attributes.delete(key_name)
9
10
  end
10
11
  end
11
12
  end
@@ -9,11 +9,10 @@ module Neo4j
9
9
  :label,
10
10
  :original_attributes
11
11
 
12
- def initialize(label:, graph_node_primary_key_name: nil, **attributes)
12
+ def initialize(label:, primary_key_name: nil, **attributes)
13
13
  @original_attributes = (attributes || {}).with_indifferent_access
14
14
  @attributes = original_attributes.dup.with_indifferent_access
15
- @key_name = graph_node_primary_key_name
16
- @key_value = @attributes.delete(key_name)
15
+ @key_name = primary_key_name
17
16
  @label = label
18
17
  end
19
18
 
@@ -3,6 +3,10 @@
3
3
  module Neo4j
4
4
  module Http
5
5
  class Relationship < ObjectWrapper
6
+ def initialize(label:, primary_key_name: nil, **attributes)
7
+ super
8
+ @key_value = @attributes.dig(key_name)
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -43,7 +43,7 @@ module Neo4j
43
43
  results&.first
44
44
  end
45
45
 
46
- def find_relationship(from:, relationship:, to:)
46
+ def find_relationships(from:, relationship:, to:)
47
47
  from_match_clause = build_match_selector(:from, from)
48
48
  to_match_clause = build_match_selector(:to, to)
49
49
  relationship_clause = build_match_selector(:relationship, relationship)
@@ -52,13 +52,17 @@ module Neo4j
52
52
  RETURN from, to, relationship
53
53
  CYPHER
54
54
 
55
- results = @cypher_client.execute_cypher(
55
+ @cypher_client.execute_cypher(
56
56
  cypher,
57
57
  from: from,
58
58
  to: to,
59
59
  relationship: relationship,
60
60
  access_mode: "READ"
61
61
  )
62
+ end
63
+
64
+ def find_relationship(from:, relationship:, to:)
65
+ results = find_relationships(from: from, to: to, relationship: relationship)
62
66
  results&.first
63
67
  end
64
68
 
@@ -72,6 +76,7 @@ module Neo4j
72
76
  from_selector = build_match_selector(:from, from)
73
77
  to_selector = build_match_selector(:to, to)
74
78
  relationship_selector = build_match_selector(:relationship, relationship)
79
+
75
80
  cypher = <<-CYPHER
76
81
  MATCH (#{from_selector}) - [#{relationship_selector}] - (#{to_selector})
77
82
  WITH from, to, relationship
@@ -82,6 +87,23 @@ module Neo4j
82
87
  results = @cypher_client.execute_cypher(cypher, from: from, to: to)
83
88
  results&.first
84
89
  end
90
+
91
+ def delete_relationship_on_primary_key(relationship:)
92
+ # protection against mass deletion of relationships
93
+ return if relationship.key_name.nil?
94
+
95
+ relationship_selector = build_match_selector(:relationship, relationship)
96
+
97
+ cypher = <<-CYPHER
98
+ MATCH () - [#{relationship_selector}] - ()
99
+ WITH relationship
100
+ DELETE relationship
101
+ RETURN relationship
102
+ CYPHER
103
+
104
+ results = @cypher_client.execute_cypher(cypher, relationship: relationship)
105
+ results&.first
106
+ end
85
107
  end
86
108
  end
87
109
  end
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Http
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3.then"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3.then
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stawarz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-19 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -121,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  version: 2.3.0
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - ">"
125
125
  - !ruby/object:Gem::Version
126
- version: '0'
126
+ version: 1.3.1
127
127
  requirements: []
128
128
  rubygems_version: 3.3.11
129
129
  signing_key: