Class: CypherBuilder::Adapter::Neography

Inherits:
Object
  • Object
show all
Defined in:
lib/cypher_builder/adapter/neography.rb

Instance Method Summary collapse

Constructor Details

#initialize(neo = ::Neography::Rest.new) ⇒ Neography

Returns a new instance of Neography.



2
3
4
# File 'lib/cypher_builder/adapter/neography.rb', line 2

def initialize(neo = ::Neography::Rest.new)
  @neo = neo
end

Instance Method Details

#execute(query, params) ⇒ Array<Hash{Symbol => Object}>

Parameters:

  • query (#to_s)
  • params (#to_h)

Returns:

  • (Array<Hash{Symbol => Object}>)


9
10
11
12
13
14
# File 'lib/cypher_builder/adapter/neography.rb', line 9

def execute(query, params)
  result = @neo.execute_query(query.to_s, params.to_h)
  columns = result['columns'].map { |it| it.to_sym }
  data = result['data']
  data.map { |values| columns.zip(values).to_h }
end