Sha256: 11df60c3f738737eb4a156f2a41fc16d4fa375d6f99eb0daac502191d7bc7052

Contents?: true

Size: 1015 Bytes

Versions: 6

Compression:

Stored size: 1015 Bytes

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|
          label, property = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)[1, 2]
          { type: row.type.to_sym, label: label.to_sym, properties: [property.to_sym], state: row.state.to_sym }
        end
      end

      def constraints
        result = query('CALL db.indexes()', {}, skip_instrumentation: true)

        result.select { |row| row.type == 'node_unique_property' }.map do |row|
          label, property = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)[1, 2]
          { type: :uniqueness, label: label.to_sym, properties: [property.to_sym] }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
activegraph-10.0.0.pre.alpha.6 lib/neo4j/core/schema.rb
neo4j-10.0.0.pre.alpha.5 lib/neo4j/core/schema.rb
neo4j-10.0.0.pre.alpha.4 lib/neo4j/core/schema.rb
neo4j-10.0.0.pre.alpha.3 lib/neo4j/core/schema.rb
neo4j-10.0.0.pre.alpha.2 lib/neo4j/core/schema.rb
neo4j-10.0.0.pre.alpha.1 lib/neo4j/core/schema.rb