유튜브 클론 #10 | mongoose functions

noo·2021년 8월 4일
0

.

목록 보기
10/12
post-thumbnail

노마드코더 유튜브 클론 챌린지 12일차 TIL


exists() : 존재 여부 확인(true or false), filter를 인자로 받음
findById() : id를 가지고 존재하는 것들을 가져옴

📌middleware

model생성 전에 만들어야 함

pre

schema.pre('save', async function() {
  await doStuff();
  await doMoreStuff();
});

📌model 메소드

static

modelSchema.static('formatHashtags', function(hashtags) {
    return hashtags.split(",").map((word) => (word.startsWith("#") ? word : `#${word}`));
});

참고
https://mongoosejs.com/docs/guide.html


시작도 안 했다는데,,.. 넘 어렵다~,~ 뭐가 너무 많아서 머릿속에서 정리가 안된다ㅏ..
메소드도 더 많은데..
이건 나중에 다시 정리할 것 같다..,
생각보다 훨씬 빡빡하다
챌린지 끝나고 한 번 다시 돌아야겠,,다

정규식은 나중에 찾아보기

0개의 댓글