【发布时间】:2016-12-08 01:09:25
【问题描述】:
我正在尝试从同一个节点创建多个关系,就我而言,我的用户需要能够在我的帖子中多次发表评论。我通过在 User 和 Post 之间建立关系来做到这一点。但是当我尝试创建它时,它实际上更新了旧的关系。 我做错什么了吗?有没有更好的方法来做到这一点?
graph.schema.create_uniqueness_constraint('COMMENTS', 'uuid')
def comment(self, post_uuid, comment):
post = self.graph.find_one('Post','uuid', post_uuid)
user = self.graph.find_one('User','uuid', self.uuid)
r_comment = Relationship(user, "COMMENTS", post, comment=comment, uuid=uuid4().hex, date=str(datetime.utcnow()))
self.graph.create(r_comment)
return True
【问题讨论】:
标签: python neo4j relationship py2neo