Skip to content

Commit

Permalink
[Add] feed 정보 가지고 오기 api #33 #24
Browse files Browse the repository at this point in the history
why
contents와 createdAt보다 많은 정보가 피드에 필요함

how
게시글에 딸린 댓글, 작성자, 좋아요 갯수, 좋아요 여부를 포함해서 반환하도록 쿼리 작성
  • Loading branch information
WooYeonSeo committed Nov 26, 2019
1 parent 05d4ad9 commit 49a0026
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion server/src/schema/feed/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@ where feed.createdAt < datetime({cursor})
RETURN user.nickname as nickname, user.thumbnail as thumbnail ,
feed.content as content ,apoc.convert.toString(feed.createdAt) as createdAt
LIMIT {first} `;
export { MATCH_NEW_FEEDS };

const MATCH_FEEDS = `MATCH (searchUser:User)-[:AUTHOR]->(feed:Feed)
OPTIONAL MATCH (likeUser:User)-[:LIKE]->(feed)
OPTIONAL MATCH (feed)-[:HAS]->(com:Comment)
WITH searchUser, feed, COLLECT(likeUser) AS cp , COLLECT(com) as comments
where feed.createdAt < datetime({cursor})
RETURN searchUser , feed , length(cp) AS totallikes,
length(filter(x IN cp WHERE x.email='[email protected]')) AS hasLiked, comments
LIMIT {first} `;

const MATCH_NEW_FEEDS2 = `MATCH (user:User { email: '[email protected]' })-[:AUTHOR]->(feed:Feed)
where feed.createdAt < datetime('9999-12-31T09:29:26.050Z')
RETURN feed`;

export { MATCH_NEW_FEEDS, MATCH_NEW_FEEDS2, MATCH_FEEDS };

0 comments on commit 49a0026

Please sign in to comment.