cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Obtaining node uuid and parent uuid

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".
3X_e_5_e5e9676b0a38b544d4678b38b91f6bad00bbfe0f.png

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

1 REPLY 1

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]