소개
게시글
질문&답변
2023.04.27
Apple Developer에서 fcm설정에 관하여 질문있습니다.
감사합니다!
- 0
- 2
- 257
질문&답변
2021.07.06
s3 질문있습니다
아 그렇군요! 감사합니다. 한가지 더 궁금한게 있습니다. 만약 인스타그램과 같이 자신의 사진으로 저장하고 공유하는 용도로 s3를 이용하게 된다면 그때는 모든사람에게 사진이 보여져야 하니까 퍼블릭엑세스를 활성화 하지도 않고 암호화를 하지도 않아야 하는것이 맞나요?ㅎㅎ
- 1
- 2
- 152
질문&답변
2021.01.16
질문있습니다.
감사합니다!!
- 0
- 6
- 372
질문&답변
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
- 372
질문&답변
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
- 372