Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-03-2022 04:29 PM
Hi all,
I'm using neomodel and I have the following models:
class ForumElement(StructuredNode):
uid = UniqueIdProperty()
created_at = DateTimeProperty(default=dt.datetime.utcnow())
text = StringProperty()
is_visible = BooleanProperty(default=True)
picture = Relationship(Picture, 'HAS_PICTURE')
author = Relationship(User, 'HAS_USER')
class Post(ForumElement):
title = StringProperty(default="")
latitude = FloatProperty()
longitude = FloatProperty()
tags = Relationship(Tag, 'HAS_TAGS')
class Comment(ForumElement):
parent = Relationship(ForumElement, 'HAS_PARENT')
With that code I have in the database something like the following, where in blue we have "comments" and in pink we have "post".
Now, I would like to have as result of a query a list of couple <parent.uid, childen.uid>, how could I obtain that? Notice that the parent of a Comment could be a Post or another Comment
04-03-2022 07:57 PM
The following should work:
match(child:Comment)-[:HAS_PARENT]->(parent)
where parent:Comment or parent:Post
return [parent.uid, child.uid]
If you only have comment and post nodes with the has_parent relationship, you could simplify it as follows:
match(child:)-[:HAS_PARENT]->(parent)
return [parent.uid, child.uid]
All the sessions of the conference are now available online