Neo4django Relationship properties

霸气de小男生 提交于 2019-12-07 06:30:33

问题


So I've trying to model a small user-group relationship in Neo4j with Django. I am currently employing the Neo4django python package seen here. Now, I have nodes representing my users, and nodes representing my groups, and relationships that link them indicating membership. What I'm hoping to also do in the near future is add properties to this relationship such as date_joined. I looked around but there isn't too much documentation on how to achieve this. I'm sure there is a way of doing it, just haven't seen any examples around.

Below is the declaration for my model.py if necessary, I think it's pretty straight forward.

class User(models.NodeModel):
    friends = models.Relationship('User', rel_type=Outgoing.FRIEND, related_single=False, related_name='friends')
    groups = models.Relationship('Group', rel_type=Outgoing.USER_GROUPS, related_single=False, related_name='groups')
    user_name = models.StringProperty(max_length=30, indexed=True)
    password = models.StringProperty(max_length=128)

class Group(models.NodeModel):
    users = models.Relationship('User', rel_type=Outgoing.MEMBER, related_single=False, related_name='members')
    group_type = models.Relationship('GroupType', rel_type=Outgoing.GROUP_TYPE, related_single=True, related_name='group_type')
    group_name = models.StringProperty(max_length=128, indexed=True)
    date_creation = models.DateProperty()

Thanks for any pointers!


回答1:


According to the people maintaining Neo4django, there is work in progress to allow user to inherit from neo4django.db.model.Relationship in order to add properties similar to Models. This has yet to be implemented. The workaround in the meantime is to use a node in between two nodes to store properties about the relationship.



来源:https://stackoverflow.com/questions/13092066/neo4django-relationship-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!