-
Notifications
You must be signed in to change notification settings - Fork 276
Neo4j v3 Setup
Installation of Neo4j Server and start server:
rake neo4j:install[community-2.1.3]
rake neo4j:start
Example, Open a session to the neo4j server database (in IRB for example)
Neo4j::Session.open(:server_db)
After you have created a session you can now use the database, see below.
On JRuby you can access the database in two different ways: using the embedded db or the server db.
Example, Open a session to the neo4j embedded database (running in the same JVM)
session = Neo4j::Session.open(:embedded_db, '/folder/db')
session.start
Example of a rails config/application.rb
file:
config.neo4j.session_options = { basic_auth: { username: 'foo', password: 'bar'} }
config.neo4j.session_type = :server_db
config.neo4j.session_path = 'http://localhost:7474'
All options from HTTParty are available. For more Information see http://rdoc.info/github/jnunemaker/httparty/HTTParty/ClassMethods
See https://gist.github.com/andreasronge/11189170 how to configure the Neo4j::Session with basic authentication from a none rails application.
A _classname
property is added to all nodes during creation to store the object's class name. This prevents an extra query to the database when wrapping the node in a Ruby class. To change the property name, add this to application.rb
:
config.neo4j[:class_name_property] = :new_name
Add a Neo4j db to your application:
heroku addons:add graphenedb
Example of a rails config/application.rb
file:
config.neo4j.session_type = :server_db
config.neo4j.session_path = ENV["GRAPHENEDB_URL"] || 'http://localhost:7474'
rails new myapp -m http://andreasronge.github.com/neo4j/neo4j.rb -O
cd myapp
rake neo4j:install[community-2.0.2]
rake neo4j:start
rails generate scaffold User name:string email:string
rails s
open http://localhost:3000/users
Or manually modify the rails config file config/application.rb
:
require 'neo4j/railtie'
module Blog
class Application < Rails::Application
# This is for embedded db, only available from JRuby
#config.neo4j.session_type = :embedded_db # or server_db
#config.neo4j.session_path = File.expand_path('neo4j-db', Rails.root) # or http://localhost:port
end
end
You can skip Active Record by using the -O flag when generating the rails project.
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