-
Notifications
You must be signed in to change notification settings - Fork 276
Project Introduction
Neo4j.rb is an ActiveRecord replacement for Rails supporting Neo4j 2.1+.
Compared to Neo4j.rb 2.x, 3.0 is a complete rebuild that boasts support for Ruby MRI using the Neo4j REST endpoint, a smaller and simpler codebase, improved Cypher Query DSL, and a more ActiveRecord-like feel. Neo4j embedded is still supported for those seeking its performance benefits under JRuby and the Neo4j embedded traversal API. See the Setup section for configuration.
v4 builds upon v3, adjusting defaults and removing the need for _classname
properties when used with Neo4j 2.1.5+.
Introduction screencast: https://www.youtube.com/watch?v=bDjbqRL9HcM Introduction blog: http://www.jayway.com/2014/09/06/neo4j-rb-3-0-rc/
class Student
include Neo4j::ActiveNode
property :name
property :age
has_many :out, :lessons, type: 'enrolled_in'
end
class Lesson
include Neo4j::ActiveNode
property :subject
has_many :in, :students, origin: :lessons
end
sandra = Student.find_by(name: 'Sandra', age: 15)
# sandra's lessons
sandra.lessons.each{|l| puts l.full_name }
# sandra's classmates
sandra.lessons.students.each_with_rel{ |student, rel| puts "#{student.name} is enrolled in #{rel.to_node.subject}" }
# sandra's classmates, age < 16
sandra.lessons.students(:s).where('s.age < {age}').params(age: 16).each_with_rel{|student, rel| puts "#{student.name} is enrolled in #{rel.to_node.subject" }
Neo4j.rb uses neo4j-core for database communication, its Cypher DSL, and many of its basic methods and classes. Please see that gem's README for more information, as familiarity with it will be helpful as you learn this gem.
WARNING: Much of the information in this wiki is out of date. We are in the process of moving things to readthedocs
- Project Introduction
- Neo4j::ActiveNode
- Neo4j::ActiveRel
- Search and Scope
- Validation, Uniqueness, and Case Sensitivity
- Indexing VS Legacy Indexing
- Optimized Methods
- Inheritance
- Core: Nodes & Rels
- Introduction
- Persistence
- Find : Lucene
- Relationships
- Third Party Gems & extensions
- Scaffolding & Generators
- HA Cluster