Model
-
Model, Schema 설정Study/Node, React 기초 강의_John Ahn 2023. 2. 12. 12:50
Model이란? Schema를 감싸주는 역할이다. Schema란? 하나하나의 정보를 지정해 줄 수 있는 것이다. User.js 생성 프로젝트에 models라는 이름의 폴더를 만들고 User.js라는 파일을 생성한다. // mongoose를 요청함 const mongoose = require('mongoose'); // Schema 설정 const userSchema = mongoose.Schema({ name: { type: String, maxlength: 50 }, email: { type: String, trim: true, unique: 1 }, password: { type: String, minlength: 5 }, lastname: { tpye: String, maxlength: 50 }, ..