Git Product home page Git Product logo

neo4j's Introduction

Welcome to Neo4j.rb

Neo4j.rb is a graph database for JRuby.

You can think of Neo4j as a high-performance graph engine with all the features of a mature and robust database. The programmer works with an object-oriented, flexible network structure rather than with strict and static tables — yet enjoys all the benefits of a fully transactional, enterprise-strength database.

It uses two powerful and mature Java libraries:

  • Neo4J - for persistence and traversal of the graph

  • Lucene for querying and indexing.

Documentation

Why Neo4j.rb or a Graph Database ?

Here are some of the major benefits of Neo4j.rb

  • Domain Modeling - use the language of a graph (nodes/relationship/properties) to express your domain !

    • Schema Less and Efficient storage of Semi Structured Information

    • No O/R mismatch - very natural to map a graph to an Object Oriented language like Ruby.

  • Performance

  • Embedded Database - no database tier, easier to install, test, deploy and configure. It is run in the same process as your application.

  • Express Queries as Traversals

    • Fast deep traversal instead of slow SQL queries that span many table joins.

    • Very natural to express graph related problem with traversals (recommendation engine, find shortest parth etc..)

  • Seamless integration with Ruby on Rails.

  • ACID Transaction with rollbacks support.

Some Examples

Neo4j::Node

Example of creating a Neo4j::Node

require "rubygems"
require 'neo4j'

Neo4j::Transaction.run do
  node = Neo4j::Node.new (:name => 'andreas')
  node.outgoing(:friends) << Neo4j::Node.new (:name => 'peter')
  node.outgoing(:friends).each {|node| puts "name #{node[:name]}"}
end

Neo4j::Mapping::NodeMixin

Example of mapping a ruby class to a node and delaring properties and relationships and lucene index.

class Person
  include Neo4j::NodeMixin
  property :name
  property :city

  has_n :friends
  has_one :address
  index :name
end

# assume we have an transaction already running
andreas = Person.new (:name => 'andreas')
andreas.friends << Person.new (:name => 'peter')
andreas.friends.each {|person| puts "name #{person.name}" }
Person.find("name: andreas").first.name # => 'andreas'

Neo4j::Rails::Model

Example of using Neo4j with Rails 3 (ActiveModel)

class User < Neo4j::Model
  attr_accessor :password
  attr_accessible :email, :password, :password_confirmation, :pending_account

  after_save   :encrypt_password

  email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

  property :email
  index :email

  has_one(:avatar).to(Avator)

  validates :email, :presence => true,:format   => { :with => email_regex }
  validates :email, :uniqueness => true, :unless => :pending_account?
  accepts_nested_attributes_for :avatar, :allow_destroy => true

  ...
end

Generate a Rails Application

Example of creating an Neo4j Application from scratch:

gem install rails
rails new myapp -m http://andreasronge.github.com/rails3.rb
cd myapp
bundle
rails generate scaffold User name:string email:string
rails s
open a webbrowser: http://localhost:3000/users

To run it with Tomcat instead of WEBrick

gem install trinidad
trinidad

Presentation Materials and other URLs

Project information

Contributing

Have you found a bug, need help or have a patch ? Just clone neo4j.rb and send me a pull request or email me. Do you need help - send me an email (andreas.ronge at gmail dot com). Please also check/add issues at lighthouse, neo4j.lighthouseapp.com

License

neo4j's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.