codingPpushu's dev story

Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.

0%

TIL-210402

What?

Full stack - Clone Coding
relationship async / await try catch multer
mongdb database

How?

  • Comment Model
    => relationship : 서로 다른 Schema를 가진 데이터가 문맥상(웹 상에서) 연관성을 가지고 있을 때 서로의 Schema를 ref를 통해 연결 시켜준다. / id(데이터 이름)만 넘기는 방식

  • Home Controller
    => async / await : 프라미스 반환 / 프라미스 처리를 기다린다 (결과는 그 이후 반환)
    => try catch : error를 잡아서 throw 해준다

  • Uploading and Creating a Video
    => file upload시 파일 자체를 db에 저장하는 것이 아닌 file의 location을 넘긴다.
    => file을 Upload하고 URL을 반환하는 middleware를 만든다.
    => multer 설치 후 video 폴더 재지정
    => mongdb database 수정 방법

  • Getting Video by ID
    => search에서 query로 trem 받은것처럼 video id를 받음
    => url로부터 정보를 가져오는 유일한 방법 : (:)과 이름을 넣으면 됨

  • Editing a Video
    => video 수정시 title, description에 빈 공간 없게 수정