Module: Neo4j::ActiveNode::Labels::Index::ClassMethods

Extended by:
Forwardable
Defined in:
lib/neo4j/active_node/labels/index.rb

Instance Method Summary collapse

Instance Method Details

#constraint(property, _constraints = {type: :unique}) ⇒ Object

Creates a neo4j constraint on this class for given property

Examples:

Person.constraint :name, type: :unique


32
33
34
# File 'lib/neo4j/active_node/labels/index.rb', line 32

def constraint(property, _constraints = {type: :unique})
  Neo4j::ModelSchema.add_defined_constraint(self, property)
end

#index(property) ⇒ Object

Creates a Neo4j index on given property

This can also be done on the property directly, see Neo4j::ActiveNode::Property::ClassMethods#property.

Examples:

class Person
   include Neo4j::ActiveNode
   property :name
   index :name
 end

Parameters:

  • property (Symbol)

    the property we want a Neo4j index on



22
23
24
25
26
# File 'lib/neo4j/active_node/labels/index.rb', line 22

def index(property)
  return if Neo4j::ModelSchema.defined_constraint?(self, property)

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