Hi the below is within the context of Neo4j GraphQL (so I need to ensure I'm returning nodes here, rather than Maps or anything, I think).
I have nodes
Posts where users can write or repost posts. Essentially posts have
created_date fields but when a user "reposts" that post, I would like to get the time of that repost.
The typical relationships look like this:
Where posts have created_date fields. When a user reposts it, the underlying post doesn't change, they just add a REPOSTED relationship to that post. Like this:
And when I want to look at a user's posts, I want to grab any that they've written or reposted and sort them in the order of either the post.created_date if they
WROTE the post or
REPOSTED time if they reposted it.
I have no idea what I should be doing here, so I attempted something like this but it isn't editing the repost_date in time (it doesn't return the correct result).
MATCH (u:User)-[r:WROTE|REPOSTED]->(post:Post) WITH (CASE WHEN r.created_date IS NOT NULL THEN r.created_date ELSE post.date END) as repost_date, post SET post.repost_date = repost_date RETURN post, repost_date ORDER BY repost_date DESC LIMIT 10
Additionally, if all I want to do is return the value, it doesn't make sense to use
SET here as it shouldn't be rewriting any post nodes.
Is there another way to grab and return both dates (when both exist, i.e. it's a REPOST)?
Thank you in advance!