Module: ActiveGraph::Core::Schema

Included in:
Base
Defined in:
lib/active_graph/core/schema.rb

Instance Method Summary collapse

Instance Method Details

#constraintsObject



20
21
22
23
24
25
26
# File 'lib/active_graph/core/schema.rb', line 20

def constraints
  raw_indexes do |keys, result|
    result.select(&method(v4?(keys) ? :v4_filter : :v3_filter)).map do |row|
      { type: :uniqueness, label: label(keys, row), properties: properties(row) }
    end
  end
end

#indexesObject



11
12
13
14
15
16
17
18
# File 'lib/active_graph/core/schema.rb', line 11

def indexes
  raw_indexes do |keys, result|
    result.map do |row|
      { type: row[:type].to_sym, label: label(keys, row), properties: properties(row),
        state: row[:state].to_sym }
    end
  end
end

#raw_indexesObject



28
29
30
31
32
33
# File 'lib/active_graph/core/schema.rb', line 28

def raw_indexes
  read_transaction do
    result = query('CALL db.indexes()', {}, skip_instrumentation: true)
    yield result.keys, result.reject { |row| row[:type] == 'LOOKUP' }
  end
end

#versionObject



4
5
6
7
8
9
# File 'lib/active_graph/core/schema.rb', line 4

def version
  read_transaction do
    # BTW: community / enterprise could be retrieved via `result.first.edition`
    query('CALL dbms.components()', {}, skip_instrumentation: true).first[:versions][0]
  end
end