Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- include Java
- import org.neo4j.api.core.Node
- import org.neo4j.api.core.RelationshipType
- import org.neo4j.api.core.EmbeddedNeo
- import org.neo4j.api.core.Transaction
- class Family
- include RelationshipType
- attr_accessor :name
- def initialize(name)
- @name = name
- end
- end
- if __FILE__ == $0
- neo = EmbeddedNeo.new('dysingers')
- tx = Transaction.begin
- begin
- tim = neo.create_node
- tim.set_property('first_name', "Tim")
- tim.set_property('last_name', "Dysinger")
- sara = neo.create_node
- sara.set_property('first_name', "Sara")
- sara.set_property('last_name', "Dysinger")
- marriage = tim.create_relationship_to(sara, Family.new('marriage'))
- marriage.set_property('date', 'Dec 14, 1996')
- jacob = neo.create_node
- jacob.set_property('first_name', "Jacob")
- jacob.set_property('last_name', "Dysinger")
- tim.create_relationship_to(jacob, Family.new('parent'))
- sara.create_relationship_to(jacob, Family.new('parent'))
- tx.success
- rescue Exception => e
- puts e.inspect
- ensure
- tx.finish
- neo.shutdown
- end
- end
Add Comment
Please, Sign In to add comment