Index

None of these methods interact with the database. They only keep track of property settings in models. It could (should?) handle the actual indexing/constraining, but that’s TBD.

Constants

Methods

#constraint!

def constraint!(type = :unique)
  fail Neo4j::InvalidPropertyOptionsError, "Unable to set constraint on indexed property #{name}" if index?(:exact)
  options[:constraint] = type
end

#constraint?

def constraint?(type = :unique)
  options.key?(:constraint) && options[:constraint] == type
end

#index!

def index!(type = :exact)
  fail Neo4j::InvalidPropertyOptionsError, "Unable to set index on constrainted property #{name}" if constraint?(:unique)
  options[:index] = type
end

#index?

def index?(type = :exact)
  options.key?(:index) && options[:index] == type
end

#index_or_constraint?

def index_or_constraint?
  index?(:exact) || constraint?(:unique)
end

#unconstraint!

def unconstraint!(type = :unique)
  options.delete(:constraint) if constraint?(type)
end

#unindex!

def unindex!(type = :exact)
  options.delete(:index) if index?(type)
end