Sha256: 9a5c10678d1fe9625dff0af3e48a0e8188cfbef48d09c0658a7f1251ed3cffc1
Contents?: true
Size: 1.6 KB
Versions: 5
Compression:
Stored size: 1.6 KB
Contents
module Neo4j module Core module Schema def version result = query('CALL dbms.components()', {}, skip_instrumentation: true) # BTW: community / enterprise could be retrieved via `result.first.edition` result.first.versions[0] end def indexes result = query('CALL db.indexes()', {}, skip_instrumentation: true) result.map do |row| { type: row.type.to_sym, label: label(result, row), properties: properties(row), state: row.state.to_sym } end end def constraints result = query('CALL db.indexes()', {}, skip_instrumentation: true) result.select(&method(v4?(result) ? :v4_filter : :v3_filter)).map do |row| { type: :uniqueness, label: label(result, row), properties: properties(row) } end end def named_constraints result = query('CALL db.constraints()', {}, skip_instrumentation: true) result.columns.include?(:name) ? result : [] end private def v4_filter(row) row.uniqueness == 'UNIQUE' end def v3_filter(row) row.type == 'node_unique_property' end def label(result, row) (v34?(result) ? row.label : (v4?(result) ? row.labelsOrTypes : row.tokenNames).first).to_sym end def v4?(result) return @v4 unless @v4.nil? @v4 = result.columns.include?(:labelsOrTypes) end def v34?(result) return @v34 unless @v34.nil? @v34 = result.columns.include?(:label) end def properties(row) row.properties.map(&:to_sym) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems