노드 리액트 기초 강의 #4 MongoDB Model & Schema
오늘은 유저모델을 생성하는 법에 대해서 배울 것입니다. 유저모델이란? 유저랑 관련된 DATA들을 보관하기 위해 만듭니다. 아래 검은 배경에 스키마가 있습니다. 이렇게 하나하나 지정해주는게 스키마를 통해서 할 수 있는 것입니다. 폴더와 파일을 생성합니다. User.js에 다음과 같이 코드를 넣어줍니다. const mongoose = require('mongoose'); const userSchema = mongoose.Schema({ name: { type: String, maxlength: 50 }, email: { type: String, trim: true, unique: 1 }, password: { type: String, minlength: 5 }, lastname: { type: String,..