Module: Neoon::Model::Schema
- Defined in:
- lib/neoon/model/schema.rb
Instance Method Summary collapse
- #neo_index_create(key) ⇒ Object
- #neo_index_drop(key) ⇒ Object
- #neo_index_drop_all ⇒ Object
- #neo_index_list ⇒ Object
- #neo_index_update ⇒ Object
- #neo_schema_index_keys ⇒ Object
- #neo_schema_update ⇒ Object
Instance Method Details
#neo_index_create(key) ⇒ Object
9 10 11 12 13 14 15 |
# 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) ⇒ Object
17 18 19 20 21 22 23 |
# 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 ⇒ Object
25 26 27 |
# 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 ⇒ Object
5 6 7 |
# File 'lib/neoon/model/schema.rb', line 5 def neo_index_list _cypher_query.list_indexes end |
#neo_index_update ⇒ Object
29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
43 44 45 46 47 48 49 |
# 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 ⇒ Object
38 39 40 41 |
# File 'lib/neoon/model/schema.rb', line 38 def neo_schema_update neo_index_update neo_index_list end |