Module: Neo4j::ActiveNode::Labels::Index::ClassMethods
- Extended by:
- Forwardable
- Defined in:
- lib/neo4j/active_node/labels/index.rb
Instance Method Summary collapse
-
#constraint(property, constraints = {type: :unique}) ⇒ Object
Creates a neo4j constraint on this class for given property.
- #constraint?(property) ⇒ Boolean
- #drop_constraint(property, constraint = {type: :unique}) ⇒ Object
- #drop_index(property, options = {}) ⇒ Object
-
#index(property) ⇒ Object
Creates a Neo4j index on given property.
- #index?(property) ⇒ Boolean
Instance Method Details
#constraint(property, constraints = {type: :unique}) ⇒ Object
Creates a neo4j constraint on this class for given property
33 34 35 36 37 38 |
# File 'lib/neo4j/active_node/labels/index.rb', line 33 def constraint(property, constraints = {type: :unique}) Neo4j::Session.on_next_session_available do declared_properties.constraint_or_fail!(property, id_property_name) schema_create_operation(:constraint, property, constraints) end end |
#constraint?(property) ⇒ Boolean
61 62 63 |
# File 'lib/neo4j/active_node/labels/index.rb', line 61 def constraint?(property) mapped_label.unique_constraints[:property_keys].include?([property]) end |
#drop_constraint(property, constraint = {type: :unique}) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/neo4j/active_node/labels/index.rb', line 50 def drop_constraint(property, constraint = {type: :unique}) Neo4j::Session.on_next_session_available do declared_properties[property].unconstraint! if declared_properties[property] schema_drop_operation(:constraint, property, constraint) end end |
#drop_index(property, options = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/neo4j/active_node/labels/index.rb', line 41 def drop_index(property, = {}) Neo4j::Session.on_next_session_available do declared_properties[property].unindex! if declared_properties[property] schema_drop_operation(:index, property, ) end 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.
22 23 24 25 26 27 |
# File 'lib/neo4j/active_node/labels/index.rb', line 22 def index(property) Neo4j::Session.on_next_session_available do |_| declared_properties.index_or_fail!(property, id_property_name) schema_create_operation(:index, property) end end |
#index?(property) ⇒ Boolean
57 58 59 |
# File 'lib/neo4j/active_node/labels/index.rb', line 57 def index?(property) mapped_label.indexes[:property_keys].include?([property]) end |