Sha256: 19bc44f564fe75221f0a6f0c21399fc5c3b3638155ee20eb317b16549aad3cd3

Contents?: true

Size: 1.06 KB

Versions: 42

Compression:

Stored size: 1.06 KB

Contents

module ActiveGraph::Node::Labels
  module Index
    extend ActiveSupport::Concern

    module ClassMethods
      extend Forwardable

      def_delegators :declared_properties, :indexed_properties

      # Creates a Neo4j index on given property
      #
      # This can also be done on the property directly, see ActiveGraph::Node::Property::ClassMethods#property.
      #
      # @param [Symbol] property the property we want a Neo4j index on
      #
      # @example
      #   class Person
      #      include ActiveGraph::Node
      #      property :name
      #      index :name
      #    end
      def index(property)
        return if ActiveGraph::ModelSchema.defined_constraint?(self, property)

        ActiveGraph::ModelSchema.add_defined_index(self, property)
      end

      # Creates a neo4j constraint on this class for given property
      #
      # @example
      #   Person.constraint :name, type: :unique
      def constraint(property, _constraints = {type: :unique})
        ActiveGraph::ModelSchema.add_defined_constraint(self, property)
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
activegraph-10.1.1 lib/active_graph/node/labels/index.rb
activegraph-11.0.1-java lib/active_graph/node/labels/index.rb
activegraph-11.0.0-java lib/active_graph/node/labels/index.rb
activegraph-10.1.0 lib/active_graph/node/labels/index.rb
activegraph-11.0.0.beta.4-java lib/active_graph/node/labels/index.rb
activegraph-10.0.2 lib/active_graph/node/labels/index.rb
activegraph-11.0.0.beta.3-java lib/active_graph/node/labels/index.rb
activegraph-11.0.0.beta.2-java lib/active_graph/node/labels/index.rb
activegraph-11.0.0.beta.1-java lib/active_graph/node/labels/index.rb
activegraph-10.0.1 lib/active_graph/node/labels/index.rb
activegraph-10.0.0 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.11 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.10 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.9 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.8 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.7 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.6 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.5 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.4 lib/active_graph/node/labels/index.rb
activegraph-10.0.0.pre.beta.3 lib/active_graph/node/labels/index.rb