neo4j-http 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/neo4j/http/client.rb +1 -1
- data/lib/neo4j/http/node.rb +2 -1
- data/lib/neo4j/http/object_wrapper.rb +2 -3
- data/lib/neo4j/http/relationship.rb +4 -0
- data/lib/neo4j/http/relationship_client.rb +24 -2
- data/lib/neo4j/http/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8fbb77721438b9be5c5ccea0335ae4c8d0ae54332cbbfbb5d1bba4e99b25ca
|
4
|
+
data.tar.gz: 4c3e90c5df2d04a6925105e537f7197b4753dd3c39fd7421c10b253c73c5c50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13f5ad50bbe007ef8bc5a5b637c3b888ecc698dc17d9704436f23de17fa7ae40a8eddb3bb107b0171cfc6780b3b3a7f66a04a8abb434354cdcd0d9cc42b6a788
|
7
|
+
data.tar.gz: 227d3ca7d78a676e00ac33132fd95008a9f906f0f83422a6878fa07deaa275c76fec037f2756393dd0ca6358360384a89ea93715653399bdf7f3ac75b22cc4ad
|
data/lib/neo4j/http/client.rb
CHANGED
@@ -5,7 +5,7 @@ module Neo4j
|
|
5
5
|
class Client
|
6
6
|
CYPHER_CLIENT_METHODS = %i[execute_cypher].freeze
|
7
7
|
NODE_CLIENT_METHODS = %i[delete_node find_node_by find_nodes_by upsert_node].freeze
|
8
|
-
RELATIONSHIP_CLIENT_METHODS = %i[delete_relationship upsert_relationship].freeze
|
8
|
+
RELATIONSHIP_CLIENT_METHODS = %i[delete_relationship upsert_relationship delete_relationship_on_primary_key].freeze
|
9
9
|
CLIENT_METHODS = (CYPHER_CLIENT_METHODS + NODE_CLIENT_METHODS + RELATIONSHIP_CLIENT_METHODS).freeze
|
10
10
|
|
11
11
|
class << self
|
data/lib/neo4j/http/node.rb
CHANGED
@@ -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:,
|
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:,
|
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 =
|
16
|
-
@key_value = @attributes.delete(key_name)
|
15
|
+
@key_name = primary_key_name
|
17
16
|
@label = label
|
18
17
|
end
|
19
18
|
|
@@ -43,7 +43,7 @@ module Neo4j
|
|
43
43
|
results&.first
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
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
|
-
|
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
|
data/lib/neo4j/http/version.rb
CHANGED
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
|
4
|
+
version: 1.1.0
|
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-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|