module ActiveGraph::Node::Labels::Index::ClassMethods

Public Instance Methods

constraint(property, _constraints = {type: :unique}) click to toggle source

Creates a neo4j constraint on this class for given property

@example

Person.constraint :name, type: :unique
   # File lib/active_graph/node/labels/index.rb
32 def constraint(property, _constraints = {type: :unique})
33   ActiveGraph::ModelSchema.add_defined_constraint(self, property)
34 end
index(property) click to toggle source

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
   # File lib/active_graph/node/labels/index.rb
22 def index(property)
23   return if ActiveGraph::ModelSchema.defined_constraint?(self, property)
24 
25   ActiveGraph::ModelSchema.add_defined_index(self, property)
26 end