게시글
질문&답변
2023.04.27
Apple Developer에서 fcm설정에 관하여 질문있습니다.
감사합니다!
- 0
- 2
- 264
질문&답변
2021.07.06
s3 질문있습니다
아 그렇군요! 감사합니다. 한가지 더 궁금한게 있습니다. 만약 인스타그램과 같이 자신의 사진으로 저장하고 공유하는 용도로 s3를 이용하게 된다면 그때는 모든사람에게 사진이 보여져야 하니까 퍼블릭엑세스를 활성화 하지도 않고 암호화를 하지도 않아야 하는것이 맞나요?ㅎㅎ
- 1
- 2
- 167
질문&답변
2021.01.16
질문있습니다.
감사합니다!!
- 0
- 6
- 387
질문&답변
2021.01.16
질문있습니다.
질문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가 안먹히는 걸까요?.. 헷갈리네요 ㅜ
- 0
- 6
- 387
질문&답변
2021.01.16
질문있습니다.
감사합니다. 제가 디비 이해가 부족해서 더 여쭤보겠습니다...ㅜ 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가 들어가는건지 궁금합니다..
- 0
- 6
- 387
질문&답변
2021.01.15
질문있습니다.
오!! 정말 감사드립니다
- 0
- 2
- 194
질문&답변
2021.01.12
질문있습니다
제로초님 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도 배열로 들어옵니당
- 0
- 3
- 147
질문&답변
2021.01.11
안녕하세요 제로초님
정말 감사합니다. 한가지만 더 여쭙자면... 말씀하신대로 밑의 코드를 짰습니다 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가 조회되게 하려면 어떻게 해야할까요...
- 0
- 3
- 214
질문&답변
2021.01.07
질문있습니다.
a (사진) a (사진) (사진) (사진) (사진) 이렇게 되어있습니다!
- 0
- 5
- 180
질문&답변
2021.01.07
질문있습니다.
네네 폴더에 이미지가 들어있고 설정 했습니다
- 0
- 5
- 180