neography 1.3.14 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/neography/rest.rb +29 -472
- data/lib/neography/rest/batch.rb +80 -87
- data/lib/neography/rest/clean.rb +8 -10
- data/lib/neography/rest/constraints.rb +15 -25
- data/lib/neography/rest/cypher.rb +2 -6
- data/lib/neography/rest/extensions.rb +4 -8
- data/lib/neography/rest/gremlin.rb +2 -6
- data/lib/neography/rest/helpers.rb +58 -0
- data/lib/neography/rest/node_auto_indexes.rb +54 -8
- data/lib/neography/rest/node_indexes.rb +92 -17
- data/lib/neography/rest/node_labels.rb +15 -26
- data/lib/neography/rest/node_paths.rb +8 -16
- data/lib/neography/rest/node_properties.rb +45 -4
- data/lib/neography/rest/node_relationships.rb +8 -17
- data/lib/neography/rest/node_traversal.rb +7 -63
- data/lib/neography/rest/nodes.rb +21 -29
- data/lib/neography/rest/other_node_relationships.rb +6 -13
- data/lib/neography/rest/relationship_auto_indexes.rb +54 -8
- data/lib/neography/rest/relationship_indexes.rb +104 -14
- data/lib/neography/rest/relationship_properties.rb +45 -4
- data/lib/neography/rest/relationship_types.rb +4 -11
- data/lib/neography/rest/relationships.rb +6 -13
- data/lib/neography/rest/schema_indexes.rb +8 -16
- data/lib/neography/rest/spatial.rb +16 -33
- data/lib/neography/rest/transactions.rb +25 -26
- data/lib/neography/tasks.rb +2 -2
- data/lib/neography/version.rb +1 -1
- data/spec/unit/rest/batch_spec.rb +49 -50
- data/spec/unit/rest/clean_spec.rb +3 -4
- data/spec/unit/rest/constraints_spec.rb +12 -13
- data/spec/unit/rest/cypher_spec.rb +3 -4
- data/spec/unit/rest/extensions_spec.rb +5 -6
- data/spec/unit/rest/gremlin_spec.rb +5 -6
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +21 -22
- data/spec/unit/rest/node_auto_indexes_spec.rb +23 -24
- data/spec/unit/rest/node_indexes_spec.rb +42 -43
- data/spec/unit/rest/node_paths_spec.rb +10 -13
- data/spec/unit/rest/node_properties_spec.rb +22 -23
- data/spec/unit/rest/node_relationships_spec.rb +18 -39
- data/spec/unit/rest/node_traversal_spec.rb +4 -97
- data/spec/unit/rest/nodes_spec.rb +47 -48
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +23 -24
- data/spec/unit/rest/relationship_indexes_spec.rb +42 -43
- data/spec/unit/rest/relationship_properties_spec.rb +22 -23
- data/spec/unit/rest/relationship_types_spec.rb +3 -4
- data/spec/unit/rest/relationships_spec.rb +5 -6
- data/spec/unit/rest/schema_index_spec.rb +7 -8
- data/spec/unit/rest/transactions_spec.rb +10 -11
- metadata +27 -31
- data/lib/neography/rest/auto_indexes.rb +0 -64
- data/lib/neography/rest/indexes.rb +0 -102
- data/lib/neography/rest/paths.rb +0 -46
- data/lib/neography/rest/properties.rb +0 -56
- data/spec/unit/rest/paths_spec.rb +0 -69
@@ -4,12 +4,11 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe RelationshipTypes do
|
6
6
|
|
7
|
-
|
8
|
-
subject { RelationshipTypes.new(connection) }
|
7
|
+
subject { Neography::Rest.new }
|
9
8
|
|
10
9
|
it "lists all relationship types" do
|
11
|
-
connection.should_receive(:get).with("/relationship/types")
|
12
|
-
subject.
|
10
|
+
subject.connection.should_receive(:get).with("/relationship/types")
|
11
|
+
subject.list_relationship_types
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -4,17 +4,16 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe Relationships do
|
6
6
|
|
7
|
-
|
8
|
-
subject { Relationships.new(connection) }
|
7
|
+
subject { Neography::Rest.new }
|
9
8
|
|
10
9
|
it "gets a relationship" do
|
11
|
-
connection.should_receive(:get).with("/relationship/42")
|
12
|
-
subject.
|
10
|
+
subject.connection.should_receive(:get).with("/relationship/42")
|
11
|
+
subject.get_relationship("42")
|
13
12
|
end
|
14
13
|
|
15
14
|
it "deletes a relationship" do
|
16
|
-
connection.should_receive(:delete).with("/relationship/42")
|
17
|
-
subject.
|
15
|
+
subject.connection.should_receive(:delete).with("/relationship/42")
|
16
|
+
subject.delete_relationship("42")
|
18
17
|
end
|
19
18
|
|
20
19
|
end
|
@@ -4,26 +4,25 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe SchemaIndexes do
|
6
6
|
|
7
|
-
|
8
|
-
subject { SchemaIndexes.new(connection) }
|
7
|
+
subject { Neography::Rest.new }
|
9
8
|
|
10
9
|
it "create schema indexes" do
|
11
10
|
options = {
|
12
11
|
:body => '{"property_keys":["name"]}',
|
13
12
|
:headers => json_content_type
|
14
13
|
}
|
15
|
-
connection.should_receive(:post).with("/schema/index/person", options)
|
16
|
-
subject.
|
14
|
+
subject.connection.should_receive(:post).with("/schema/index/person", options)
|
15
|
+
subject.create_schema_index("person", ["name"])
|
17
16
|
end
|
18
17
|
|
19
18
|
it "get schema indexes" do
|
20
|
-
connection.should_receive(:get).with("/schema/index/person")
|
21
|
-
subject.
|
19
|
+
subject.connection.should_receive(:get).with("/schema/index/person")
|
20
|
+
subject.get_schema_index("person")
|
22
21
|
end
|
23
22
|
|
24
23
|
it "delete schema indexes" do
|
25
|
-
connection.should_receive(:delete).with("/schema/index/person/name")
|
26
|
-
subject.
|
24
|
+
subject.connection.should_receive(:delete).with("/schema/index/person/name")
|
25
|
+
subject.delete_schema_index("person","name")
|
27
26
|
end
|
28
27
|
|
29
28
|
end
|
@@ -4,16 +4,15 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe Transactions do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
subject { Neography::Rest.new }
|
8
|
+
|
10
9
|
it "can create new transactions" do
|
11
10
|
options = {
|
12
11
|
:body => '{"statements":[]}',
|
13
12
|
:headers => json_content_type
|
14
13
|
}
|
15
|
-
connection.should_receive(:post).with("/transaction", options)
|
16
|
-
subject.
|
14
|
+
subject.connection.should_receive(:post).with("/transaction", options)
|
15
|
+
subject.begin_transaction
|
17
16
|
end
|
18
17
|
|
19
18
|
it "can add to transactions" do
|
@@ -21,8 +20,8 @@ module Neography
|
|
21
20
|
:body => '{"statements":[]}',
|
22
21
|
:headers => json_content_type
|
23
22
|
}
|
24
|
-
connection.should_receive(:post).with("/transaction/1", options)
|
25
|
-
subject.
|
23
|
+
subject.connection.should_receive(:post).with("/transaction/1", options)
|
24
|
+
subject.in_transaction(1, [])
|
26
25
|
end
|
27
26
|
|
28
27
|
it "can commit transactions" do
|
@@ -30,13 +29,13 @@ module Neography
|
|
30
29
|
:body => '{"statements":[]}',
|
31
30
|
:headers => json_content_type
|
32
31
|
}
|
33
|
-
connection.should_receive(:post).with("/transaction/1/commit", options)
|
34
|
-
subject.
|
32
|
+
subject.connection.should_receive(:post).with("/transaction/1/commit", options)
|
33
|
+
subject.commit_transaction(1, [])
|
35
34
|
end
|
36
35
|
|
37
36
|
it "can rollback transactions" do
|
38
|
-
connection.should_receive(:delete).with("/transaction/1")
|
39
|
-
subject.
|
37
|
+
subject.connection.should_receive(:delete).with("/transaction/1")
|
38
|
+
subject.rollback_transaction(1)
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max De Marzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.11'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -42,98 +42,98 @@ dependencies:
|
|
42
42
|
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: httpclient
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.3.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.7.7
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.7.7
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: os
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.9.6
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.9.6
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubyzip
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 1.0.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.0.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: multi_json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.3.2
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.3.2
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 0.8.7
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.8.7
|
139
139
|
description: A Ruby wrapper to the Neo4j Rest API see http://docs.neo4j.org/chunked/stable/rest-api.html
|
@@ -143,10 +143,10 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
-
- .gitignore
|
147
|
-
- .project
|
148
|
-
- .rspec
|
149
|
-
- .travis.yml
|
146
|
+
- ".gitignore"
|
147
|
+
- ".project"
|
148
|
+
- ".rspec"
|
149
|
+
- ".travis.yml"
|
150
150
|
- CONTRIBUTORS
|
151
151
|
- ChangeLog
|
152
152
|
- Gemfile
|
@@ -179,7 +179,6 @@ files:
|
|
179
179
|
- lib/neography/relationship.rb
|
180
180
|
- lib/neography/relationship_traverser.rb
|
181
181
|
- lib/neography/rest.rb
|
182
|
-
- lib/neography/rest/auto_indexes.rb
|
183
182
|
- lib/neography/rest/batch.rb
|
184
183
|
- lib/neography/rest/clean.rb
|
185
184
|
- lib/neography/rest/constraints.rb
|
@@ -187,7 +186,6 @@ files:
|
|
187
186
|
- lib/neography/rest/extensions.rb
|
188
187
|
- lib/neography/rest/gremlin.rb
|
189
188
|
- lib/neography/rest/helpers.rb
|
190
|
-
- lib/neography/rest/indexes.rb
|
191
189
|
- lib/neography/rest/node_auto_indexes.rb
|
192
190
|
- lib/neography/rest/node_indexes.rb
|
193
191
|
- lib/neography/rest/node_labels.rb
|
@@ -197,8 +195,6 @@ files:
|
|
197
195
|
- lib/neography/rest/node_traversal.rb
|
198
196
|
- lib/neography/rest/nodes.rb
|
199
197
|
- lib/neography/rest/other_node_relationships.rb
|
200
|
-
- lib/neography/rest/paths.rb
|
201
|
-
- lib/neography/rest/properties.rb
|
202
198
|
- lib/neography/rest/relationship_auto_indexes.rb
|
203
199
|
- lib/neography/rest/relationship_indexes.rb
|
204
200
|
- lib/neography/rest/relationship_properties.rb
|
@@ -255,6 +251,7 @@ files:
|
|
255
251
|
- spec/unit/rest/cypher_spec.rb
|
256
252
|
- spec/unit/rest/extensions_spec.rb
|
257
253
|
- spec/unit/rest/gremlin_spec.rb
|
254
|
+
- spec/unit/rest/helpers_spec.rb
|
258
255
|
- spec/unit/rest/labels_spec.rb
|
259
256
|
- spec/unit/rest/node_auto_indexes_spec.rb
|
260
257
|
- spec/unit/rest/node_indexes_spec.rb
|
@@ -263,7 +260,6 @@ files:
|
|
263
260
|
- spec/unit/rest/node_relationships_spec.rb
|
264
261
|
- spec/unit/rest/node_traversal_spec.rb
|
265
262
|
- spec/unit/rest/nodes_spec.rb
|
266
|
-
- spec/unit/rest/paths_spec.rb
|
267
263
|
- spec/unit/rest/relationship_auto_indexes_spec.rb
|
268
264
|
- spec/unit/rest/relationship_indexes_spec.rb
|
269
265
|
- spec/unit/rest/relationship_properties_spec.rb
|
@@ -281,17 +277,17 @@ require_paths:
|
|
281
277
|
- lib
|
282
278
|
required_ruby_version: !ruby/object:Gem::Requirement
|
283
279
|
requirements:
|
284
|
-
- -
|
280
|
+
- - ">="
|
285
281
|
- !ruby/object:Gem::Version
|
286
282
|
version: '0'
|
287
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
288
284
|
requirements:
|
289
|
-
- -
|
285
|
+
- - ">="
|
290
286
|
- !ruby/object:Gem::Version
|
291
287
|
version: '0'
|
292
288
|
requirements: []
|
293
289
|
rubyforge_project: neography
|
294
|
-
rubygems_version: 2.2.
|
290
|
+
rubygems_version: 2.2.0
|
295
291
|
signing_key:
|
296
292
|
specification_version: 4
|
297
293
|
summary: ruby wrapper to Neo4j Rest API
|
@@ -341,6 +337,7 @@ test_files:
|
|
341
337
|
- spec/unit/rest/cypher_spec.rb
|
342
338
|
- spec/unit/rest/extensions_spec.rb
|
343
339
|
- spec/unit/rest/gremlin_spec.rb
|
340
|
+
- spec/unit/rest/helpers_spec.rb
|
344
341
|
- spec/unit/rest/labels_spec.rb
|
345
342
|
- spec/unit/rest/node_auto_indexes_spec.rb
|
346
343
|
- spec/unit/rest/node_indexes_spec.rb
|
@@ -349,7 +346,6 @@ test_files:
|
|
349
346
|
- spec/unit/rest/node_relationships_spec.rb
|
350
347
|
- spec/unit/rest/node_traversal_spec.rb
|
351
348
|
- spec/unit/rest/nodes_spec.rb
|
352
|
-
- spec/unit/rest/paths_spec.rb
|
353
349
|
- spec/unit/rest/relationship_auto_indexes_spec.rb
|
354
350
|
- spec/unit/rest/relationship_indexes_spec.rb
|
355
351
|
- spec/unit/rest/relationship_properties_spec.rb
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Neography
|
2
|
-
class Rest
|
3
|
-
class AutoIndexes
|
4
|
-
include Neography::Rest::Helpers
|
5
|
-
|
6
|
-
def initialize(connection)
|
7
|
-
@connection ||= connection
|
8
|
-
end
|
9
|
-
|
10
|
-
def get(key, value)
|
11
|
-
index = @connection.get(key_value_path(:key => key, :value => value)) || []
|
12
|
-
return nil if index.empty?
|
13
|
-
index
|
14
|
-
end
|
15
|
-
|
16
|
-
def find_or_query(key_or_query, value = nil)
|
17
|
-
if value
|
18
|
-
index = find(key_or_query, value)
|
19
|
-
else
|
20
|
-
index = query(key_or_query)
|
21
|
-
end
|
22
|
-
return nil if index.empty?
|
23
|
-
index
|
24
|
-
end
|
25
|
-
|
26
|
-
def find(key, value)
|
27
|
-
@connection.get(key_value_path(:key => key, :value => value)) || []
|
28
|
-
end
|
29
|
-
|
30
|
-
def query(query_expression)
|
31
|
-
@connection.get(query_index_path(:query => query_expression)) || []
|
32
|
-
end
|
33
|
-
|
34
|
-
def status
|
35
|
-
@connection.get(index_status_path)
|
36
|
-
end
|
37
|
-
|
38
|
-
def status=(value)
|
39
|
-
options = {
|
40
|
-
:body => value.to_json,
|
41
|
-
:headers => json_content_type
|
42
|
-
}
|
43
|
-
@connection.put(index_status_path, options)
|
44
|
-
end
|
45
|
-
|
46
|
-
def properties
|
47
|
-
@connection.get(index_properties_path)
|
48
|
-
end
|
49
|
-
|
50
|
-
def add_property(property)
|
51
|
-
options = {
|
52
|
-
:body => property,
|
53
|
-
:headers => json_content_type
|
54
|
-
}
|
55
|
-
@connection.post(index_properties_path, options)
|
56
|
-
end
|
57
|
-
|
58
|
-
def remove_property(property)
|
59
|
-
@connection.delete(index_property_path(:property => property))
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
module Neography
|
2
|
-
class Rest
|
3
|
-
class Indexes
|
4
|
-
include Neography::Rest::Helpers
|
5
|
-
|
6
|
-
def initialize(connection, index_type)
|
7
|
-
@connection ||= connection
|
8
|
-
@index_type ||= index_type
|
9
|
-
end
|
10
|
-
|
11
|
-
def list
|
12
|
-
@connection.get(all_path)
|
13
|
-
end
|
14
|
-
|
15
|
-
def create(name, type = "exact", provider = "lucene", extra_config = nil)
|
16
|
-
config = {
|
17
|
-
:type => type,
|
18
|
-
:provider => provider
|
19
|
-
}
|
20
|
-
config.merge!(extra_config) unless extra_config.nil?
|
21
|
-
options = {
|
22
|
-
:body => (
|
23
|
-
{ :name => name,
|
24
|
-
:config => config
|
25
|
-
}
|
26
|
-
).to_json,
|
27
|
-
:headers => json_content_type
|
28
|
-
}
|
29
|
-
@connection.post(all_path, options)
|
30
|
-
end
|
31
|
-
|
32
|
-
def create_auto(type = "exact", provider = "lucene")
|
33
|
-
create("#{@index_type}_auto_index", type, provider)
|
34
|
-
end
|
35
|
-
|
36
|
-
def add(index, key, value, id, unique = false)
|
37
|
-
options = {
|
38
|
-
:body => (
|
39
|
-
{ :uri => @connection.configuration + "/#{@index_type}/#{get_id(id)}",
|
40
|
-
:key => key,
|
41
|
-
:value => value
|
42
|
-
}
|
43
|
-
).to_json,
|
44
|
-
:headers => json_content_type
|
45
|
-
}
|
46
|
-
path = unique ? unique_path(:index => index) : base_path(:index => index)
|
47
|
-
@connection.post(path, options)
|
48
|
-
end
|
49
|
-
|
50
|
-
def get(index, key, value)
|
51
|
-
index = @connection.get(key_value_path(:index => index, :key => key, :value => value)) || []
|
52
|
-
return nil if index.empty?
|
53
|
-
index
|
54
|
-
end
|
55
|
-
|
56
|
-
def find(index, key_or_query, value = nil)
|
57
|
-
if value
|
58
|
-
index = find_by_key_value(index, key_or_query, value)
|
59
|
-
else
|
60
|
-
index = find_by_query(index, key_or_query)
|
61
|
-
end
|
62
|
-
return nil if index.empty?
|
63
|
-
index
|
64
|
-
end
|
65
|
-
|
66
|
-
def find_by_key_value(index, key, value)
|
67
|
-
@connection.get(key_value_path(:index => index, :key => key, :value => value)) || []
|
68
|
-
end
|
69
|
-
|
70
|
-
def find_by_query(index, query)
|
71
|
-
@connection.get(query_path(:index => index, :query => query)) || []
|
72
|
-
end
|
73
|
-
|
74
|
-
# Mimick original neography API in Rest class.
|
75
|
-
def remove(index, id_or_key, id_or_value = nil, id = nil)
|
76
|
-
if id
|
77
|
-
remove_by_value(index, id, id_or_key, id_or_value)
|
78
|
-
elsif id_or_value
|
79
|
-
remove_by_key(index, id_or_value, id_or_key)
|
80
|
-
else
|
81
|
-
remove_by_id(index, id_or_key)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def remove_by_id(index, id)
|
86
|
-
@connection.delete(id_path(:index => index, :id => get_id(id)))
|
87
|
-
end
|
88
|
-
|
89
|
-
def remove_by_key(index, id, key)
|
90
|
-
@connection.delete(key_path(:index => index, :id => get_id(id), :key => key))
|
91
|
-
end
|
92
|
-
|
93
|
-
def remove_by_value(index, id, key, value)
|
94
|
-
@connection.delete(value_path(:index => index, :id => get_id(id), :key => key, :value => value))
|
95
|
-
end
|
96
|
-
|
97
|
-
def drop(index)
|
98
|
-
@connection.delete(base_path(:index => index))
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|