neo4j-core 3.0.0.alpha.16 → 3.0.0.alpha.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -37
  3. data/lib/mydb/index/lucene-store.db +0 -0
  4. data/lib/mydb/index/lucene.log.active +0 -0
  5. data/lib/mydb/index/{lucene.log.1 → lucene.log.v0} +0 -0
  6. data/lib/mydb/messages.log +359 -0
  7. data/lib/mydb/neostore +0 -0
  8. data/lib/mydb/neostore.id +0 -0
  9. data/lib/mydb/neostore.labeltokenstore.db +0 -0
  10. data/lib/mydb/neostore.labeltokenstore.db.id +0 -0
  11. data/lib/mydb/neostore.labeltokenstore.db.names +0 -0
  12. data/lib/mydb/neostore.labeltokenstore.db.names.id +0 -0
  13. data/lib/mydb/neostore.nodestore.db +0 -0
  14. data/lib/mydb/neostore.nodestore.db.id +0 -0
  15. data/lib/mydb/neostore.nodestore.db.labels +0 -0
  16. data/lib/mydb/neostore.nodestore.db.labels.id +0 -0
  17. data/lib/mydb/neostore.propertystore.db +0 -0
  18. data/lib/mydb/neostore.propertystore.db.arrays +0 -0
  19. data/lib/mydb/neostore.propertystore.db.arrays.id +0 -0
  20. data/lib/mydb/neostore.propertystore.db.id +0 -0
  21. data/lib/mydb/neostore.propertystore.db.index +0 -0
  22. data/lib/mydb/neostore.propertystore.db.index.id +0 -0
  23. data/lib/mydb/neostore.propertystore.db.index.keys +0 -0
  24. data/lib/mydb/neostore.propertystore.db.index.keys.id +0 -0
  25. data/lib/mydb/neostore.propertystore.db.strings +0 -0
  26. data/lib/mydb/neostore.propertystore.db.strings.id +0 -0
  27. data/lib/mydb/neostore.relationshipgroupstore.db +0 -0
  28. data/lib/mydb/neostore.relationshipgroupstore.db.id +0 -0
  29. data/lib/mydb/neostore.relationshipstore.db +0 -0
  30. data/lib/mydb/neostore.relationshipstore.db.id +0 -0
  31. data/lib/mydb/neostore.relationshiptypestore.db +1 -0
  32. data/lib/mydb/neostore.relationshiptypestore.db.id +0 -0
  33. data/lib/mydb/neostore.relationshiptypestore.db.names +0 -0
  34. data/lib/mydb/neostore.relationshiptypestore.db.names.id +0 -0
  35. data/lib/mydb/neostore.schemastore.db +0 -0
  36. data/lib/mydb/neostore.schemastore.db.id +0 -0
  37. data/lib/mydb/nioneo_logical.log.active +0 -0
  38. data/lib/mydb/nioneo_logical.log.v0 +0 -0
  39. data/lib/mydb/schema/label/lucene/segments.gen +0 -0
  40. data/lib/mydb/schema/label/lucene/segments_1 +0 -0
  41. data/lib/mydb/tm_tx_log.1 +0 -0
  42. data/lib/neo4j-core.rb +1 -1
  43. data/lib/neo4j-core/helpers.rb +1 -1
  44. data/lib/neo4j-core/query.rb +298 -0
  45. data/lib/neo4j-core/query_clauses.rb +476 -0
  46. data/lib/neo4j-core/version.rb +1 -1
  47. data/lib/neo4j-core/version.rb~ +5 -0
  48. data/lib/neo4j-embedded/cypher_response.rb +9 -45
  49. data/lib/neo4j-embedded/embedded_session.rb +15 -17
  50. data/lib/neo4j-server/cypher_node.rb +16 -5
  51. data/lib/neo4j-server/cypher_relationship.rb +24 -6
  52. data/lib/neo4j-server/cypher_response.rb +35 -35
  53. data/lib/neo4j-server/cypher_session.rb +8 -12
  54. data/lib/neo4j/node.rb +4 -4
  55. data/lib/neo4j/session.rb +11 -63
  56. data/lib/neo4j/tasks/neo4j_server.rb +31 -0
  57. metadata +9 -7
  58. data/lib/mydb/lock +0 -0
  59. data/lib/mydb/nioneo_logical.log.1 +0 -0
  60. data/lib/mydb/schema/label/lucene/write.lock +0 -0
  61. data/lib/neo4j-core/query_builder.rb +0 -200
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = "3.0.0.alpha.16"
3
+ VERSION = "3.0.0.alpha.17"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ module Neo4j
2
+ module Core
3
+ VERSION = "3.0.0.alpha.16"
4
+ end
5
+ end
@@ -14,10 +14,10 @@ module Neo4j::Embedded
14
14
  # @return the original result from the Neo4j Cypher Engine, once forward read only !
15
15
  attr_reader :source
16
16
 
17
- def initialize(source, map_return_procs, query)
17
+ def initialize(source, query)
18
18
  @source = source
19
+ @struct = Struct.new(*source.columns.to_a.map(&:to_sym))
19
20
  @unread = true
20
- @map_return_procs = map_return_procs
21
21
  @query = query
22
22
  end
23
23
 
@@ -31,59 +31,23 @@ module Neo4j::Embedded
31
31
 
32
32
  # @return [Array<Symbol>] the columns in the query result
33
33
  def columns
34
- @source.columns.map { |x| x.to_sym }
34
+ @source.columns.map(&:to_sym)
35
35
  end
36
36
 
37
- # for the Enumerable contract
38
- def each(&block)
37
+ def each
39
38
  raise ResultsAlreadyConsumedException unless @unread
40
39
 
41
- if (block)
42
- case @map_return_procs
43
- when NilClass then
44
- each_no_mapping &block
45
- when Hash then
46
- each_multi_column_mapping &block
47
- else
48
- each_single_column_mapping &block
40
+ if block_given?
41
+ @source.each do |row|
42
+ yield(row.each_with_object(@struct.new) do |(column, value), result|
43
+ result[column.to_sym] = (value.respond_to?(:wrapper) ? value.wrapper : value)
44
+ end)
49
45
  end
50
46
  else
51
47
  Enumerator.new(self)
52
48
  end
53
49
  end
54
50
 
55
-
56
- private
57
-
58
- def each_no_mapping
59
- @source.each do |row|
60
- hash = {}
61
- row.each do |key, value|
62
- out[key.to_sym] = value
63
- end
64
- yield hash
65
- end
66
- end
67
-
68
- def each_multi_column_mapping
69
- @source.each do |row|
70
- hash = {}
71
- row.each do |key, value|
72
- k = key.to_sym
73
- proc = @map_return_procs[k]
74
- hash[k] = proc ? proc.call(value) : value
75
- end
76
- yield hash
77
- end
78
- end
79
-
80
- def each_single_column_mapping
81
- @source.each do |row|
82
- result = @map_return_procs.call(row.values.first)
83
- yield result
84
- end
85
- end
86
-
87
51
  end
88
52
  end
89
53
 
@@ -21,7 +21,6 @@ module Neo4j::Embedded
21
21
  @db_location = db_location
22
22
  @auto_commit = !!config[:auto_commit]
23
23
  Neo4j::Session.register(self)
24
- @query_builder = Neo4j::Core::QueryBuilder.new
25
24
  end
26
25
 
27
26
  def inspect
@@ -34,6 +33,7 @@ module Neo4j::Embedded
34
33
  factory = Java::OrgNeo4jGraphdbFactory::GraphDatabaseFactory.new
35
34
  @graph_db = factory.newEmbeddedDatabase(db_location)
36
35
  Neo4j::Session._notify_listeners(:session_available, self)
36
+ @engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(@graph_db)
37
37
  end
38
38
 
39
39
  def factory_class
@@ -85,19 +85,17 @@ module Neo4j::Embedded
85
85
  nil
86
86
  end
87
87
 
88
- def query(*params)
89
- query_hash = @query_builder.to_query_hash(params, :to_node)
90
- cypher = @query_builder.to_cypher(query_hash)
91
-
92
- result = _query(cypher, query_hash[:params])
93
- if result.respond_to?(:error?) && result.error?
94
- raise Neo4j::Session::CypherError.new(result.error_msg, result.error_code, result.error_status)
88
+ def query(*args)
89
+ if [[String], [String, String]].include?(args.map(&:class))
90
+ query, params = args[0,2]
91
+ Neo4j::Embedded::ResultWrapper.new(_query(query, params), query)
92
+ else
93
+ options = args[0] || {}
94
+ Neo4j::Core::Query.new(options.merge(session: self))
95
95
  end
96
-
97
- map_return_procs = @query_builder.to_map_return_procs(query_hash)
98
- ResultWrapper.new(result, map_return_procs, cypher)
99
96
  end
100
97
 
98
+
101
99
  def find_all_nodes(label)
102
100
  EmbeddedLabel.new(self, label).find_nodes
103
101
  end
@@ -111,10 +109,10 @@ module Neo4j::Embedded
111
109
  # @param [String] q the cypher query as a String
112
110
  # @return (see #query)
113
111
  def _query(q, params={})
114
- engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(@graph_db)
115
- engine.execute(q, Neo4j::Core::HashWithIndifferentAccess.new(params))
112
+ @engine ||= Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(@graph_db)
113
+ @engine.execute(q, Neo4j::Core::HashWithIndifferentAccess.new(params))
116
114
  rescue Exception => e
117
- raise Neo4j::Session::CypherError.new(e.message, e.class, 'cypher error')
115
+ raise Neo4j::Session::CypherError.new(e.message, e.class, 'cypher error')
118
116
  end
119
117
 
120
118
  def query_default_return(as)
@@ -122,8 +120,8 @@ module Neo4j::Embedded
122
120
  end
123
121
 
124
122
  def _query_or_fail(q)
125
- engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(@graph_db)
126
- engine.execute(q)
123
+ @engine ||= Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(@graph_db)
124
+ @engine.execute(q)
127
125
  end
128
126
 
129
127
  def search_result_to_enumerable(result)
@@ -146,4 +144,4 @@ module Neo4j::Embedded
146
144
 
147
145
 
148
146
 
149
- end
147
+ end
@@ -3,9 +3,16 @@ module Neo4j::Server
3
3
  include Neo4j::Server::Resource
4
4
  include Neo4j::Core::CypherTranslator
5
5
 
6
- def initialize(session, id)
6
+ def initialize(session, value)
7
7
  @session = session
8
- @id = id
8
+
9
+ @id = if value.is_a?(Hash)
10
+ @response_hash = value
11
+ @props = @response_hash['data']
12
+ @response_hash['self'].match(/\d+$/)[0].to_i
13
+ else
14
+ value
15
+ end
9
16
  end
10
17
 
11
18
  def neo_id
@@ -30,8 +37,12 @@ module Neo4j::Server
30
37
 
31
38
  # (see Neo4j::Node#props)
32
39
  def props
33
- props = @session._query_or_fail("START n=node(#{neo_id}) RETURN n", true)['data']
34
- props.keys.inject({}){|hash,key| hash[key.to_sym] = props[key]; hash}
40
+ if @props
41
+ @props
42
+ else
43
+ props = @session._query_or_fail("START n=node(#{neo_id}) RETURN n", true)['data']
44
+ props.keys.inject({}){|hash,key| hash[key.to_sym] = props[key]; hash}
45
+ end
35
46
  end
36
47
 
37
48
  # (see Neo4j::Node#remove_property)
@@ -187,4 +198,4 @@ module Neo4j::Server
187
198
  end
188
199
 
189
200
  end
190
- end
201
+ end
@@ -4,10 +4,24 @@ module Neo4j::Server
4
4
  include Neo4j::Server::Resource
5
5
  include Neo4j::Core::CypherTranslator
6
6
 
7
- def initialize(session, id, rel_type)
7
+ attr_reader :start_node_neo_id, :end_node_neo_id
8
+
9
+ def initialize(session, value, rel_type = nil)
8
10
  @session = session
9
- @id = id
10
- @rel_type = rel_type
11
+
12
+ @id = if value.is_a?(Hash)
13
+ @response_hash = value
14
+ @rel_type = @response_hash['type']
15
+ @props = @response_hash['data']
16
+ @start_node_neo_id = @response_hash['start'].match(/\d+$/)[0].to_i
17
+ @end_node_neo_id = @response_hash['end'].match(/\d+$/)[0].to_i
18
+
19
+ @response_hash['self'].match(/\d+$/)[0].to_i
20
+ else
21
+ @rel_type = rel_type
22
+
23
+ value
24
+ end
11
25
  end
12
26
 
13
27
  def ==(o)
@@ -59,8 +73,12 @@ module Neo4j::Server
59
73
 
60
74
  # (see Neo4j::Relationship#props)
61
75
  def props
62
- props = @session._query_or_fail("START n=relationship(#{neo_id}) RETURN n", true)['data']
63
- props.keys.inject({}){|hash,key| hash[key.to_sym] = props[key]; hash}
76
+ if @props
77
+ @props
78
+ else
79
+ props = @session._query_or_fail("START n=relationship(#{neo_id}) RETURN n", true)['data']
80
+ props.keys.inject({}){|hash,key| hash[key.to_sym] = props[key]; hash}
81
+ end
64
82
  end
65
83
 
66
84
  # (see Neo4j::Relationship#props=)
@@ -102,4 +120,4 @@ module Neo4j::Server
102
120
  end
103
121
 
104
122
  end
105
- end
123
+ end
@@ -21,10 +21,10 @@ module Neo4j::Server
21
21
  def_delegator :@response, :error_code
22
22
  def_delegator :@response, :data
23
23
  def_delegator :@response, :columns
24
+ def_delegator :@response, :struct
24
25
 
25
- def initialize(response, map_return_procs, query)
26
+ def initialize(response, query)
26
27
  @response = response
27
- @map_return_procs = map_return_procs
28
28
  @query = query
29
29
  end
30
30
 
@@ -36,48 +36,41 @@ module Neo4j::Server
36
36
  "Enumerable query: '#{@query}'"
37
37
  end
38
38
 
39
- def each_no_mapping
40
- data.each do |row|
41
- hash = {}
42
- row.each_with_index do |row, i|
43
- key = columns[i].to_sym
44
- hash[key] = row
45
- end
46
- yield hash
47
- end
48
- end
49
-
50
- def each_multi_column_mapping
39
+ def each(&block)
51
40
  data.each do |row|
52
- hash = {}
53
- row.each_with_index do |row, i|
54
- key = columns[i].to_sym
55
- proc = @map_return_procs[key]
56
- hash[key] = proc ? proc.call(row) : row
57
- end
58
- yield hash
41
+ yield(row.each_with_index.each_with_object(struct.new) do |(value, i), result|
42
+ result[columns[i].to_sym] = value
43
+ end)
59
44
  end
60
45
  end
46
+ end
61
47
 
62
- def each_single_column_mapping
63
- data.each do |row|
64
- result = @map_return_procs.call(row.first)
65
- yield result
66
- end
67
- end
48
+ def to_struct_enumeration(cypher = '')
49
+ HashEnumeration.new(self, cypher)
50
+ end
68
51
 
69
- def each(&block)
70
- case @map_return_procs
71
- when NilClass then each_no_mapping &block
72
- when Hash then each_multi_column_mapping &block
73
- else each_single_column_mapping &block
52
+ def to_node_enumeration(cypher = '', session = Neo4j::Session.current)
53
+ Enumerator.new do |yielder|
54
+ self.to_struct_enumeration(cypher).each do |row|
55
+ yielder << row.each_pair.each_with_object(@struct.new) do |(column, value), result|
56
+
57
+ result[column] = if value.is_a?(Hash)
58
+ if value['labels']
59
+ CypherNode.new(session, value).wrapper
60
+ elsif value['type']
61
+ CypherRelationship.new(session, value).wrapper
62
+ else
63
+ value
64
+ end
65
+ else
66
+ value
67
+ end
68
+ end
74
69
  end
75
70
  end
76
71
  end
77
72
 
78
- def to_hash_enumeration(map_return_procs={}, cypher='')
79
- HashEnumeration.new(self, map_return_procs, cypher)
80
- end
73
+ attr_reader :struct
81
74
 
82
75
  def initialize(response, uncommited = false)
83
76
  @response = response
@@ -108,6 +101,7 @@ module Neo4j::Server
108
101
  def set_data(data, columns)
109
102
  @data = data
110
103
  @columns = columns
104
+ @struct = columns.empty? ? Object.new : Struct.new(*columns.map(&:to_sym))
111
105
  self
112
106
  end
113
107
 
@@ -124,6 +118,12 @@ module Neo4j::Server
124
118
  raise ResponseError.new(@error_msg, @error_status, @error_code)
125
119
  end
126
120
 
121
+ def raise_cypher_error
122
+ raise "Tried to raise error without an error" unless @error
123
+ raise Neo4j::Session::CypherError.new(@error_msg, @error_code, @error_status)
124
+ end
125
+
126
+
127
127
  def self.create_with_no_tx(response)
128
128
  case response.code
129
129
  when 200
@@ -35,7 +35,6 @@ module Neo4j::Server
35
35
  Neo4j::Session.register(self)
36
36
  initialize_resource(data_url)
37
37
  Neo4j::Session._notify_listeners(:session_available, self)
38
- @query_builder = Neo4j::Core::QueryBuilder.new
39
38
  end
40
39
 
41
40
  def to_s
@@ -131,17 +130,14 @@ module Neo4j::Server
131
130
  search_result_to_enumerable_first_column(response)
132
131
  end
133
132
 
134
- def query(*params)
135
- query_hash = @query_builder.to_query_hash(params, :id_to_node)
136
- cypher = @query_builder.to_cypher(query_hash)
137
-
138
- result = _query(cypher, query_hash[:params])
139
- if result.error?
140
- raise Neo4j::Session::CypherError.new(result.error_msg, result.error_code, result.error_status)
133
+ def query(*args)
134
+ if [[String], [String, String]].include?(args.map(&:class))
135
+ query, params = args[0,2]
136
+ _query(query, params).to_node_enumeration(query)
137
+ else
138
+ options = args[0] || {}
139
+ Neo4j::Core::Query.new(options.merge(session: self))
141
140
  end
142
-
143
- map_return_procs = @query_builder.to_map_return_procs(query_hash)
144
- result.to_hash_enumeration(map_return_procs, cypher)
145
141
  end
146
142
 
147
143
  def _query_or_fail(q, single_row = false, params=nil)
@@ -207,4 +203,4 @@ module Neo4j::Server
207
203
  end
208
204
  end
209
205
  end
210
- end
206
+ end
data/lib/neo4j/node.rb CHANGED
@@ -180,25 +180,25 @@ module Neo4j
180
180
  end
181
181
 
182
182
  # Loads a node from the database with given id
183
- def load(neo_id, session = Neo4j::Session.current)
183
+ def load(neo_id, session = Neo4j::Session.current!)
184
184
  node = _load(neo_id, session)
185
185
  node && node.wrapper
186
186
  end
187
187
 
188
188
  # Same as #load but does not try to return a wrapped node
189
189
  # @return [Neo4j::Node] an unwrapped node
190
- def _load(neo_id, session = Neo4j::Session.current)
190
+ def _load(neo_id, session = Neo4j::Session.current!)
191
191
  session.load_node(neo_id)
192
192
  end
193
193
 
194
194
  # Checks if the given entity node or entity id (Neo4j::Node#neo_id) exists in the database.
195
195
  # @return [true, false] if exist
196
- def exist?(entity_or_entity_id, session = Neo4j::Session.current)
196
+ def exist?(entity_or_entity_id, session = Neo4j::Session.current!)
197
197
  session.node_exist?(neo_id)
198
198
  end
199
199
 
200
200
  # Find the node with given label and value
201
- def find_nodes(label, value=nil, session = Neo4j::Session.current)
201
+ def find_nodes(label, value=nil, session = Neo4j::Session.current!)
202
202
  session.find_nodes(label, value)
203
203
  end
204
204
  end
data/lib/neo4j/session.rb CHANGED
@@ -46,71 +46,14 @@ module Neo4j
46
46
  end
47
47
  end
48
48
 
49
- # Executes a Cypher Query.
50
- # Returns an enumerable of hash values where each hash corresponds to a row unless +return+ or +map_return+
51
- # is not an array. The search result can be mapped to Neo4j::Node or Neo4j::Relationship is your own Ruby wrapper class
52
- # by specifying a map_return parameter.
49
+ # Returns a Query object. See Neo4j::Core::Query for more details, but basic usage looks like:
53
50
  #
54
- # @param [Hash, String] q the cypher query, as a pure string query or a hash which will generate a cypher string.
55
- # @option q [Hash] :params cypher parameters
56
- # @option q [Symbol,Hash] :label the label to match. You can specify several labels by using a hash of variable names and labels.
57
- # @option q [Symbol] :conditions key and value of properties which the label nodes must match
58
- # @option q [Hash] :conditions key and value of properties which the label nodes must match
59
- # @option q [String, Array] :match the cypher match clause
60
- # @option q [String, Array] :where the cypher where clause
61
- # @option q [String, Array, Symbol] :return the cypher where clause
62
- # @option q [String, Hash, Symbol] :map_return mapping of the returned values, e.g. :id_to_node, :id_to_rel, or :value
63
- # @option q [Hash<Symbol, Proc>] :map_return_procs custom mapping functions of :map_return types
64
- # @option q [String,Symbol,Array<Hash>] :order the order
65
- # @option q [Fixnum] :limit enables the return of only subsets of the total result.
66
- # @option q [Fixnum] :skip enables the return of only subsets of the total result.
67
- # @return [Enumerable] the result, an enumerable of Neo4j::Node objects unless a pure cypher string is given or return/map_returns is specified, see examples.
68
- # @raise CypherError if invalid cypher
69
- # @example Cypher String and parameters
70
- # Neo4j::Session.query("START n=node({p}) RETURN ID(n)", params: {p: 42})
71
- #
72
- # @example label
73
- # # If there is no :return parameter it will try to return Neo4j::Node objects
74
- # # Default parameter is :n in the generated cypher
75
- # Neo4j::Session.query(label: :person) # => MATCH (n:`person`) RETURN ID(n) # or RETURN n for embedded
76
- #
77
- # @example to_s
78
- # # What Cypher is returned ? check with to_s
79
- # Neo4j::Session.query(label: :person).to_s # =>
80
- #
81
- # @example return
82
- # Neo4j::Session.query(label: :person, return: :age) # returns age properties
83
- # Neo4j::Session.query(label: :person, return: [:name, :age]) # returns a hash of name and age properties
84
- # Neo4j::Session.query(label: :person, return: 'count(n) AS c')
85
- #
86
- # @example map_return - an Enumerable of names (String)
87
- # Neo4j::Session.query("START n=node(42) RETURN n.name", map_return: :value)
88
- #
89
- # @example map_return - Enumerable of an Hash with name property, Neo4j::Relationship and Neo4j::Node as values
90
- # Neo4j::Session.query("START n=node(42) MATCH n-[r]->[x] RETURN n.name as N, ID(r) as R, ID(x) as X",
91
- # map_return: {N: :value, R: :id_to_rel, X: :id_to_node})
92
- #
93
- # @example map_return, only for embedded_db, to_rel, and to_node allows direct mapping to Neo4j::Node and Neo4j::Relationship without ID(n)
94
- # Neo4j::Session.query("START n=node(42) MATCH n-[r]->[x] RETURN n.name as N, r, x", map_return: {N: :value, r: :to_rel, x: :to_node})
95
- #
96
- # @example map_return_procs, custom mapping function
97
- # Neo4j::Session.query(label: :person, map_return: :age_times_two, map_return_procs: {age_times_two: ->(row){(row[:age] || 0) * 2}})
98
- #
99
- # @example match
100
- # Neo4j::Session.query(label: :person, match: 'n--m')
101
- #
102
- # @example where
103
- # Neo4j::Session.query(label: :person, where: 'n.age > 40')
104
- # Neo4j::Session.query(label: :person, where: 'n.age > {age}', params: {age: 40})
105
- #
106
- # @example condition
107
- # Neo4j::Session.query(label: :person, conditions: {age: 42})
108
- # Neo4j::Session.query(label: :person, conditions: {name: /foo?bar.*/})
51
+ # @example
52
+ # session.query.match("(c:Car)<-[:OWNS]-(p:Person)").where(c: {vin: '234UAEB3425B'}).return(:p).first[:p]
109
53
  #
110
54
  # @see http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html The Cypher Query Language Documentation
111
- # @note Returns a read-once only forward iterable for the embedded database.
112
55
  #
113
- def query(q)
56
+ def query(options = {})
114
57
  raise 'not implemented, abstract'
115
58
  end
116
59
 
@@ -145,9 +88,14 @@ module Neo4j
145
88
  @@current_session
146
89
  end
147
90
 
91
+ def current!
92
+ raise "No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db" unless current
93
+ current
94
+ end
95
+
148
96
  # @see Neo4j::Session#query
149
- def query(*params)
150
- current.query(*params)
97
+ def query(options = {})
98
+ current!.query(options)
151
99
  end
152
100
 
153
101
  def named(name)