Class: RailsGraph::Exporters::Neo4j

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_graph/exporters/neo4j.rb

Class Method Summary collapse

Class Method Details

.build_query(graph) ⇒ Object



23
24
25
26
27
# File 'lib/rails_graph/exporters/neo4j.rb', line 23

def self.build_query(graph)
  queries = Cypher.build_queries(graph)
  queries.shift
  queries.join("\n")
end

.export(graph:, host:, username:, password:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rails_graph/exporters/neo4j.rb', line 9

def self.export(graph:, host:, username:, password:)
  auth = ::Neo4j::Driver::AuthTokens.basic(username, password)

  ::Neo4j::Driver::GraphDatabase.driver(host, auth) do |driver|
    driver.session do |session|
      queries = build_query(graph)

      session.write_transaction do |tx|
        tx.run(queries, message: "Success!")
      end
    end
  end
end