Sha256: 32d1820e510d66d05f24e1189f22bbd8b8d79ef9a7ddfba359e2a9207f2351c1

Contents?: true

Size: 1.04 KB

Versions: 92

Compression:

Stored size: 1.04 KB

Contents

module Neo4j::ActiveNode::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 Neo4j::ActiveNode::Property::ClassMethods#property.
      #
      # @param [Symbol] property the property we want a Neo4j index on
      #
      # @example
      #   class Person
      #      include Neo4j::ActiveNode
      #      property :name
      #      index :name
      #    end
      def index(property)
        return if Neo4j::ModelSchema.defined_constraint?(self, property)

        Neo4j::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})
        Neo4j::ModelSchema.add_defined_constraint(self, property)
      end
    end
  end
end

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
neo4j-9.6.2 lib/neo4j/active_node/labels/index.rb
activegraph-10.0.0.pre.alpha.11 lib/neo4j/active_node/labels/index.rb
activegraph-10.0.0.pre.alpha.10 lib/neo4j/active_node/labels/index.rb
activegraph-10.0.0.pre.alpha.9 lib/neo4j/active_node/labels/index.rb
activegraph-10.0.0.pre.alpha.8 lib/neo4j/active_node/labels/index.rb
activegraph-10.0.0.pre.alpha.7 lib/neo4j/active_node/labels/index.rb
activegraph-10.0.0.pre.alpha.6 lib/neo4j/active_node/labels/index.rb
neo4j-10.0.0.pre.alpha.5 lib/neo4j/active_node/labels/index.rb
neo4j-10.0.0.pre.alpha.4 lib/neo4j/active_node/labels/index.rb
neo4j-10.0.0.pre.alpha.3 lib/neo4j/active_node/labels/index.rb
neo4j-10.0.0.pre.alpha.2 lib/neo4j/active_node/labels/index.rb
neo4j-10.0.0.pre.alpha.1 lib/neo4j/active_node/labels/index.rb
neo4j-9.6.1 lib/neo4j/active_node/labels/index.rb
neo4j-9.6.0 lib/neo4j/active_node/labels/index.rb
neo4j-9.5.3 lib/neo4j/active_node/labels/index.rb
neo4j-9.5.2 lib/neo4j/active_node/labels/index.rb
neo4j-9.5.0 lib/neo4j/active_node/labels/index.rb
neo4j-9.4.0 lib/neo4j/active_node/labels/index.rb
neo4j-9.3.0 lib/neo4j/active_node/labels/index.rb
neo4j-9.2.4 lib/neo4j/active_node/labels/index.rb