Skip to content

Commit

Permalink
[Add] 쿼리 export 방식 변경 #140
Browse files Browse the repository at this point in the history
컨벤션에 맞춰서 export 방식 변경
  • Loading branch information
WooYeonSeo committed Dec 4, 2019
1 parent d68b38a commit 3c1fbe5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 11 additions & 0 deletions client/src/hooks/useUserInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, { useState, useEffect } from 'react';
const useUserInfo = () => {
// state를 생성합니다.
const [email, setEmail] = useState('');
useEffect(() => {
//
}, []);
return email;
};

export default useUserInfo;
12 changes: 5 additions & 7 deletions server/src/schema/feed/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const MATCH_FEEDS = `MATCH (searchUser:User)-[:AUTHOR]->(feed:Feed)
export const MATCH_FEEDS = `MATCH (searchUser:User)-[:AUTHOR]->(feed:Feed)
OPTIONAL MATCH (likeUser:User)-[like:LIKE]->(feed)
OPTIONAL MATCH (feed)-[:HAS]->(com:Comment)
OPTIONAL MATCH (feed)<-[:HAS]-(img:Image)
Expand All @@ -10,18 +10,18 @@ order by feed.createdAt desc
LIMIT {first}
`;

const UPDATE_LIKE = `
export const UPDATE_LIKE = `
MATCH (u:User),(f:Feed)
WHERE u.email = {useremail} AND ID(f) = {feedId}
MERGE (u)-[r:LIKE]->(f)
RETURN type(r)`;

const DELETE_LIKE = `
export const DELETE_LIKE = `
MATCH (u:User)-[r:LIKE]->(f:Feed)
WHERE u.email = {useremail} AND ID(f) = {feedId}
delete r`;

const GET_NEW_FEED = `MATCH (searchUser:User)-[:AUTHOR]->(feed:Feed)
export const GET_NEW_FEED = `MATCH (searchUser:User)-[:AUTHOR]->(feed:Feed)
OPTIONAL MATCH (likeUser:User)-[like:LIKE]->(feed)
OPTIONAL MATCH (feed)-[:HAS]->(com:Comment)
OPTIONAL MATCH (feed)<-[:HAS]-(img:Image)
Expand All @@ -32,9 +32,7 @@ length(filter(x IN cp WHERE x.email= {useremail} )) AS hasLiked, comments
order by feed.createdAt desc
`;

const GET_FRIENDS = `MATCH (searchUser:User)-[:FRIEND]->(friend:User)
export const GET_FRIENDS = `MATCH (searchUser:User)-[:FRIEND]->(friend:User)
where searchUser.email = {userEmail} and friend.email = {friendEmail}
with collect(friend) as t
return length(t) as isFriend`;

export { MATCH_FEEDS, UPDATE_LIKE, DELETE_LIKE, GET_NEW_FEED, GET_FRIENDS };

0 comments on commit 3c1fbe5

Please sign in to comment.