Let's start with the ownership relationship. In order to materialize it in our user, we need to add the following line:
class User(StructuredNode):
# ... same as above
owned_repositories = RelationshipTo("Repository", "OWNS")
This allows us to query the repositories from the users:
User.nodes.get(login="me").owned_repositories.all()
# [<Repository: {'name': 'hogan', 'id': 47}>]
If we also need to perform the operation the other way around – that is, from the repositories to the users – we also need to add the opposite relationship to the Repository model:
class Repository(StructuredNode):
# ... same as above
owner = RelationshipFrom(User, "OWNS")
We can also get the owner from the repository:
Repository.nodes.get(name="hogan").owner.get()
# <User: {'login': 'me', 'password': '<3Graphs', 'email...