Sha256: 3c8dddd287a5ee58d15c3244262c2cf911dc614e4a94d43d583e5ce5b10c7747
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
module ActiveGraph 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activegraph-10.0.0.pre.beta.3 | lib/active_graph/core/schema.rb |
activegraph-10.0.0.pre.beta.2 | lib/active_graph/core/schema.rb |
activegraph-10.0.0.pre.beta.1 | lib/active_graph/core/schema.rb |