Created
June 23, 2015 13:26
-
-
Save subvertallchris/d8a3f684bcf08cb7a2f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
include Neo4j::ActiveNode | |
property :name, type: String | |
property :age, type: Integer | |
has_many :out, :houses, type: 'OWNS_PROPERTY' | |
has_many :out, :vehicles, type: 'OWNS_VEHICLE' | |
end | |
class House | |
include Neo4j::ActiveNode | |
property :address, type: String | |
has_many :in, :people, origin: :houses | |
end | |
class Vehicle | |
include Neo4j::ActiveNode | |
property :year | |
has_many :in, :owners, model_class: 'Person', origin: :vehicles | |
end | |
# To create a relationship, you can use << to append a new node or = to reset all relationships | |
person = Person.create(name: 'James', age: 15) | |
house = House.create(address: '560 Broadway') | |
person.houses << house |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As to adding a second relationship type, I think you were asking about how that would be represented. I think it's best to come up with different association names in that case. Like this: