Got a wall post type scenario where I'd like to spill out posts by you, your friends, and sort them chronologically with a limit
Is there a way to do this without using a union?
like, I'd almost like something like this (if you'll forgive the pseudo-query):
match (a:Account)-([:FRIEND]->(friend:Account)-)?[:POST]->(post:Post)
where id(a) = 0
return friend,post
I'm just wondering how to get your posts as well as your friends posts in one query
Right now I have (0 is the id of the logged in account right now):
match (a:Account)-[:FRIEND]->(friend:Account)-[:POST]->(post:Post)
where id(a) = 0
return friend,post
union
match (friend:Account)-[:POST]->(post:Post)
where id(friend) = 0
return friend,post
order by post.date_created DESC
limit 10
and while this works in acquiring all the desired posts I want (according to my tests), the order by only seems to organize based on the individual result sets and not as the whole unioned result set
basically this should not be my resulting json:
[{"id":4,"date_created":1438621410,"content":"This is a test post!","account":{"id":10,"username":"test","email":"test@test.com"}},{"id":5,"date_created":1438621422,"content":"about to try this thing","account":{"id":0,"username":"test2","email":"test2@gmail.com"}}]
it should be
[{"id":5,"date_created":1438621422,"content":"about to try this thing","account":{"id":0,"username":"test2","email":"test2@gmail.com"}}, {"id":4,"date_created":1438621410,"content":"This is a test post!","account":{"id":10,"username":"test","email":"test@test.com"}}]
any pointers?