Module: Neo4j::ActiveNode::IdProperty

Extended by:
ActiveSupport::Concern
Includes:
Accessor
Included in:
Neo4j::ActiveNode
Defined in:
lib/neo4j/active_node/id_property.rb,
lib/neo4j/active_node/id_property/accessor.rb

Overview

This module makes it possible to use other IDs than the build it neo4j id (neo_id)

Examples:

using generated UUIDs

class Person
  include Neo4j::ActiveNode
  # creates a 'secret' neo4j property my_uuid which will be used as primary key
  id_property :my_uuid, auto: :uuid
end

using user defined ids

class Person
  include Neo4j::ActiveNode
  property :title
  validates :title, :presence => true
  id_property :title_id, on: :title_to_url

  def title_to_url
    self.title.urlize # uses https://github.com/cheef/string-urlize gem
  end
end

using already exsting ids that you don’t want a constraint added to

class Person
  include Neo4j::ActiveNode
  property :title
  validates :title, :presence => true
  id_property :id, on: :id_builder, constraint: false

  def id_builder
    # only need to fill this out if you're gonna write to the db
  end
end

Defined Under Namespace

Modules: Accessor, ClassMethods, TypeMethods

Instance Attribute Summary

Attributes included from Accessor

#default_property_value

Method Summary

Methods included from Accessor

#default_properties, #default_properties=, #default_property, #default_property_key