module Neoon::Model::Schema

Public Instance Methods

neo_index_create(key) click to toggle source
# File lib/neoon/model/schema.rb, line 9
def neo_index_create key
  if neo_schema_index_keys.select { |k,v| v == 'UNIQUENESS' }.include? key
    _cypher_query.create_constraint(key)
  else
    _cypher_query.create_index(key)
  end
end
neo_index_drop(key) click to toggle source
# File lib/neoon/model/schema.rb, line 17
def neo_index_drop key
  if neo_index_list[key] == 'UNIQUENESS'
    _cypher_query.drop_constraint(key)
  else
    _cypher_query.drop_index(key)
  end
end
neo_index_drop_all() click to toggle source
# File lib/neoon/model/schema.rb, line 25
def neo_index_drop_all
  neo_index_list.each { |k, _| neo_index_drop(k) }
end
neo_index_list() click to toggle source
# File lib/neoon/model/schema.rb, line 5
def neo_index_list
  _cypher_query.list_indexes
end
neo_index_update() click to toggle source
# File lib/neoon/model/schema.rb, line 29
def neo_index_update
  cl, ck = neo_index_list.to_a, neo_schema_index_keys.to_a
  return cl if cl == ck
  return neo_index_drop_all if ck.empty?

  (cl - ck).each{ |k| neo_index_drop(k.first) } unless (cl - ck).empty?
  (ck - cl).each{ |k| neo_index_create(k.first) } unless (ck - cl).empty?
end
neo_schema_index_keys() click to toggle source
# File lib/neoon/model/schema.rb, line 43
def neo_schema_index_keys
  neo_model_config.properties.inject({}) do |all, (k, v)|
    all[k] = true if v[:index]
    all[k] = 'UNIQUENESS' if v[:index] == :unique
    all
  end
end
neo_schema_update() click to toggle source
# File lib/neoon/model/schema.rb, line 38
def neo_schema_update
  neo_index_update
  neo_index_list
end

Protected Instance Methods

_cypher_query() click to toggle source
# File lib/neoon/model/schema.rb, line 53
def _cypher_query
  Neoon::Cypher::Query.new(self)
end