Posts
Q&A
Parallel Routes์ ๋ํ์ฌ ์ง๋ฌธ์์ต๋๋ค.
์ธํ๋ฐ Ai ์ธํด์ ๋ต๋ณ๊ณผ ์กฐ๊ธ ๋ค๋ฅธ ๋ฌธ์ ?์ธ ๊ฒ ๊ฐ์ต๋๋น.
- Likes
- 0
- Comments
- 3
- Viewcount
- 390
Q&A
Apple Developer์์ fcm์ค์ ์ ๊ดํ์ฌ ์ง๋ฌธ์์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค!
- Likes
- 0
- Comments
- 2
- Viewcount
- 469
Q&A
s3 ์ง๋ฌธ์์ต๋๋ค
์ ๊ทธ๋ ๊ตฐ์! ๊ฐ์ฌํฉ๋๋ค. ํ๊ฐ์ง ๋ ๊ถ๊ธํ๊ฒ ์์ต๋๋ค. ๋ง์ฝ ์ธ์คํ๊ทธ๋จ๊ณผ ๊ฐ์ด ์์ ์ ์ฌ์ง์ผ๋ก ์ ์ฅํ๊ณ ๊ณต์ ํ๋ ์ฉ๋๋ก s3๋ฅผ ์ด์ฉํ๊ฒ ๋๋ค๋ฉด ๊ทธ๋๋ ๋ชจ๋ ์ฌ๋์๊ฒ ์ฌ์ง์ด ๋ณด์ฌ์ ธ์ผ ํ๋๊น ํผ๋ธ๋ฆญ์์ธ์ค๋ฅผ ํ์ฑํ ํ์ง๋ ์๊ณ ์ํธํ๋ฅผ ํ์ง๋ ์์์ผ ํ๋๊ฒ์ด ๋ง๋์?ใ ใ
- Likes
- 1
- Comments
- 2
- Viewcount
- 351
Q&A
์ง๋ฌธ์์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค!!
- Likes
- 0
- Comments
- 6
- Viewcount
- 677
Q&A
์ง๋ฌธ์์ต๋๋ค.
์ง๋ฌธ1. db.Post.belongsToMany(db.User, { through: 'Follow', as: 'Followers', foreignKey: 'FollowingId' }); ์ด๋ ๊ฒ ๋์ด์์ผ๋ฉด post๋ชจ๋ธ์ด Follwers๊ฐ ๋๊ณ foreginkey๊ฐ FollwingId๊ฐ ๋๋๊ฒ์ธ๊ฐ์??.... ์ง๋ฌธ2. ๋ง์ฝ ๊ทธ๋ ๋ค๋ฉด router.get('/', async (req, res, next) => { // GET /user try { if (req.user) { const fullUserWithoutPassword = await User.findOne({ where: { id: req.user.id }, attributes: { exclude: ['password'] }, include: [ { model: Post, attributes: ['id'], }, { model: Post, as: 'Followings', attributes: ['id'], }, // { // model: Post, // as: 'Followers', // attributes: ['id'], // } ] }) // console.log("fullUserWithoutPassword::::::::::::",JSON.stringify(fullUserWithoutPassword),"enddddddddddddd"); res.status(200).json(fullUserWithoutPassword); } else { res.status(200).json(null); } } catch (error) { console.error(error); next(error); } }); ์์ ๋ผ์ฐํฐ์์ Post์์ as๋ฅผ Followings๋ฅผ ํด์ผ๋ง ๊ฐ์ ธ์ฌ ์ ์๋๋ผ๊ตฌ์. Follwers๋ฅผ๋ฃ์ผ๋ฉด ์ค๋ฅ๊ฐ๋๋๋ผ๊ตฌ์ฅ.. ์์ ๋ผ์ฐํฐ๋ ์ post as Follwers๊ฐ ์๋จนํ๋ ๊ฑธ๊น์?.. ํท๊ฐ๋ฆฌ๋ค์ ใ
- Likes
- 0
- Comments
- 6
- Viewcount
- 677
Q&A
์ง๋ฌธ์์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค. ์ ๊ฐ ๋๋น ์ดํด๊ฐ ๋ถ์กฑํด์ ๋ ์ฌ์ญค๋ณด๊ฒ ์ต๋๋ค...ใ db.User.belongsToMany(db.Post, { through: 'Follow', as: 'Followings', foreignKey: 'FollowerId' }); db.Post.belongsToMany(db.User, { through: 'Follow', as: 'Followers', foreignKey: 'FollowingId' }); ์์์ฒ๋ผ post๋ชจ๋ธ์ ์ด๋ฆ์ Followings์ด๊ณ foreignKey๋ FollwerId์ด๊ณ User๋ชจ๋ธ์ Follwers ์ด๊ณ foriegnKey๋ FollowingId์ด์์์? ๊ทธ๋ฐ๋ฐ ํ๋ก์ฐํ๋ ๋ผ์ฐํฐ์์ ์ด๋ ๊ฒ ์ ํด์คฌ์ ์ router.patch('/:PostId/follow', isLoggedIn, async (req, res, next) => { // PATCH /user/1/follow try { const post = await Post.findOne({ where: { id: req.params.PostId }}); if (!post) { res.status(403).send('์๋ ์ฌ๋์ ํ๋ก์ฐํ๋ ค๊ณ ํ์๋ค์?'); } await post.addFollowers(req.user.id); res.status(200).json({ PostId: parseInt(req.params.PostId, 10) }); } catch (error) { console.error(error); next(error); } }); ํ๋ก์ฐ๋ฅผ ํ๋ฉด (์ฐธ๊ณ ๋ก req.user.id)๋ 1์ด๊ณ req.params.PostId๊ฐ 2์ ๋๋ค.) (์ฌ์ง) ๋ฐ์ดํฐ๋ฒ ์ด์ค์ Follwerid๊ฐ 1 FollowingId๊ฐ 2๋ก ๋์ต๋๋ค. ์ ๋ ๋น์ฐํ Post๋ชจ๋ธ ์ฆ Followings์ foreignKey๊ฐ FollwerId์ด๊ธฐ ๋๋ฌธ์ FollwerId์ 2๊ฐ ๋ค์ด๊ฐ ์ค ์์๋๋ฐ. ๋ฐ๋๊ฐ ๋๋ค์?? post๋ชจ๋ธ์ forignKey๊ฐ FollwerId์ธ๋ฐ ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค์๋ FollowingId์ 2๊ฐ ๋ค์ด๊ฐ๋๊ฑด์ง ๊ถ๊ธํฉ๋๋ค..
- Likes
- 0
- Comments
- 6
- Viewcount
- 677
Q&A
์ง๋ฌธ์์ต๋๋ค.
์ค!! ์ ๋ง ๊ฐ์ฌ๋๋ฆฝ๋๋ค
- Likes
- 0
- Comments
- 2
- Viewcount
- 339
Q&A
์ง๋ฌธ์์ต๋๋ค
์ ๋ก์ด๋ case COOK_UP_SUCCESS: draft.loadPostsLoading = false; draft.loadPostsDone = true; for(let i = 0; i action.data.legnth; i++) { if ( action.data[i].id !== draft.mainPosts[i].id ){ draft.mainPosts = draft.mainPosts.concat(action.data[i]); }} draft.hasMorePosts = action.data.length === 10; break; case COOK_UP_SUCCESS: draft.loadPostsLoading = false; draft.loadPostsDone = true; const ha = draft.mainPosts for(let i = 0; i action.data.legnth; i++) { if ( action.data[i].id !== ha[i].id ){ draft.mainPosts = draft.mainPosts.concat(action.data[i]); }} draft.hasMorePosts = action.data.length === 10; break; case COOK_UP_SUCCESS: draft.loadPostsLoading = false; draft.loadPostsDone = true; const ha = draft.mainPosts for(let i = 0; i action.data.legnth; i++) { if ( action.data[i].id !== ha[i].id ){ draft.mainPosts = ha.concat(action.data[i]); }} draft.hasMorePosts = action.data.length === 10; break; ์ด๋ฌํ ๋ฐฉ์๋ค๋ก for๋ฌธ์ ๋๋ ค๋ดค๋๋ฐ ๋ฐ์ดํฐ๊ฐ ํ๋๋ ์๋ค์ด์ค๋ค์ ใ ๋ฆฌ๋์ ์์์ ๋ญ ํ๋๊ฒ ์์ง ์ต์์น ์๋ค์ ใ ์ด๋ป๊ฒ ํด์ผํ ๊น์ ์ฐธ๊ณ ๋ก action.data๋ ๋ฐฐ์ด๋ก ๋ค์ด์ต๋๋น
- Likes
- 0
- Comments
- 3
- Viewcount
- 295
Q&A
์๋ ํ์ธ์ ์ ๋ก์ด๋
์ ๋ง ๊ฐ์ฌํฉ๋๋ค. ํ๊ฐ์ง๋ง ๋ ์ฌ์ญ์๋ฉด... ๋ง์ํ์ ๋๋ก ๋ฐ์ ์ฝ๋๋ฅผ ์งฐ์ต๋๋ค case LIKE_POST_SUCCESS: draft.singlePost[action.data.PostId]; draft.likePostLoading = false; draft.likePostDone = true; break; router.patch('/:postId/like', isLoggedIn, async (req, res, next) => { // PATCH /post/1/like try { // console.log("req.params.postId::::::::",req.params.postId); const post = await Post.findOne( { where: { id: req.params.postId }}); if (!post) { return res.status(403).send('๊ฒ์๊ธ์ด ์กด์ฌํ์ง ์์ต๋๋ค.'); } await post.addLikers(req.user.id); res.json({ PostId: post.id, UserId: req.user.id }); } catch (error) { console.error(error); next(error); } }); ๊ทธ๋ฐ๋ฐ LKIE_POST_SUCESS์ก์ ์ด ์คํ ๋๊ณ ๋ฆฌ๋์ค์์ ํ์ธํ๋ฉด singlePost๊ฐ์ฒด์ Likers๊ฐ (์ฌ์ง) ์ด๋ ๊ฒ ๋น ๋ฐฐ์ด๋ก ์กฐํ๋๊ณ ์๋ก๊ณ ์นจ์ ํ๋ฉด LOAD_POST_REQUEST์ก์ ์ด ์คํ๋์ด ๋ฐ์ ๋ผ์ฐํฐ๊ฐ ์คํ๋๊ณ router.post('/', upload.none(), async (req, res, next) => { // POST /post const fullPost = await Post.findOne({ where: { id: post.id }, include: [{ model: Image, }, { model: User, // ๊ฒ์๊ธ ์์ฑ์ attributes: ['id', 'nickname'], }, { model: User, // ์ข์์ ๋๋ฅธ ์ฌ๋ as: 'Likers', attributes: ['id'], }] }) // console.log("fullpost::::::::::::::::::",JSON.stringify(fullPost),"endddddddddddddd"); res.status(201).json(fullPost); } catch (error) { console.error(error); next(error); } }); case LOAD_POST_SUCCESS: draft.loadPostLoading = false; draft.loadPostDone = true; draft.singlePost = action.data; break; ์์ ์ก์ ์ด ์คํ๋๊ณ ๊ทธ๋์์ผ LKIE_POST_SUCESS์ ์ ๋ ฅํ๋ ๊ฐ์ด (์ฌ์ง) Likers์์ ์กฐํ๊ฐ ๋๋ค์. LKIE_POST_SUCESS์ ๋ฆฌ๋์ค์์ Likers๊ฐ ์กฐํ๋๊ฒ ํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผํ ๊น์...
- Likes
- 0
- Comments
- 3
- Viewcount
- 370
Q&A
์ง๋ฌธ์์ต๋๋ค.
a (์ฌ์ง) a (์ฌ์ง) (์ฌ์ง) (์ฌ์ง) (์ฌ์ง) ์ด๋ ๊ฒ ๋์ด์์ต๋๋ค!
- Likes
- 0
- Comments
- 5
- Viewcount
- 334




