User.js에서 userSchema를 만들 때 unique:true 로 설정을 하게 되면 똑같은 값을 db에 생성할 수 없다. (ex/ username, email)
bcrypt를 통해 password를 hashing 할 수 있다. User.js에서 "pre" middleware를 사용해서 password를 hashing 한다.
userSchema.pre("save", async function() { this.password = await bcrypt.hash(this.password, 5) })
5가 의미하는 것은 password를 몇 번 hashing 할 것인지 정하는 것이다.
or operator를 통해서 2개 이상의 db 안의 값을 비교할 수 있다.
const exists = User.exists({$or: [{username}], [{email}] })
res.status(400).render({})
.status() 를 통해 원하는 status code를 브라우저에 보낼 수 있다.