I have a social media scenario as seen in image(Case 1) and wanted to create newsfeed for a user which will include posts of the nodes he is following and also his own posts. and for that I was using this cypher query :
MATCH (:User{id: "MThIs8ibezSjylKBxux7qdusDyu1"})-[:FOLLOWS]->(b) WITH b.id
as uids
MATCH (u:User) -[:POSTED]-> (p:Post)
WHERE u.id in uids
OR u.id in ["MThIs8ibezSjylKBxux7qdusDyu1"]
RETURN p.caption , p.timeStamp ,p.linksArray , p.postId ORDER BY p.timeStamp DESC
this works perfectly fine unless a scenario occurs where the current node does not follow anyone Case 2.
Now Logically it should return the posts of the current node too but that's not the case.If the user is following someone it returns posts from both of them but if the user is following no one it returns nothing. As I'm new to neo4j I would really appreciate your help.