1
我有以下查询:检查用户是否喜欢这个岗位
MATCH (user:User)-[:CREATED]->(post:Post)
WITH user, post
ORDER BY post.createdAt DESC
OPTIONAL MATCH (post)<-[:BELONGS_TO]-(comment:Comment)<-[:COMMENTED]-(:User)
WITH user, post, liked, comment
ORDER BY comment.timestamp DESC
WITH user, post, liked, COLLECT(comment)[0..4] AS comments
RETURN post,
{ username: user.username,
firstName: user.firstName,
lastName: user.lastName,
profilePicture: user.profilePicture
} AS createdBy,
size((post)<-[:LIKES]-(:User)) AS likes,
liked,
comments
SKIP {skip}
LIMIT {limit}
的查询获取职位列表,并计算出其他的东西,如: GET发表评论,得到是谁创造的帖子的用户,得到的总数喜欢。
我还需要计算,如果我喜欢这个帖子或不是,这将导致:userLiked(true | false)。
我想的是一样的东西:
OPTIONAL MATCH (post)<-[userLiked:LIKES]-(:User {uuid: {userUUID}})
对于这个SKIP和LIMIT - 如果我想分页结果不起作用。 –
啊,如果你想先按评论时间戳排序,这是有道理的。我将SKIP和LIMIT移到了返回之前,这应该仍然可以避免对您计划返回的页面中未包含的结果进行不必要的操作。 – InverseFalcon
基本上,我希望最新的帖子首先包含每篇帖子的最新评论。看起来你编辑的文章工作正常。谢谢! –