우리가 웹 사이트 이용할 때 보통 회원가입을 하게 된다.
이름도 입력하고, 생년월일도 입력하고.. 웹사이트에서 요구하는 다양한 정보를 입력한다.
이런 정보들은 User Database에 들어가는데, 이렇게 유저와 관련된 데이터들을 보관하기 위해서
User Model(유저 모델), User Schema(유저 스키마) 를 간단히 알아보자!
User Model
Model은 Schema를 감싸주는 역할
Schema
const mongoose = require('mongoose')
const Schema = mongoose.Schema;
const bookSchema = mongoose.Schema({
writer: {
type: Schema.Types.ObjectId,
ref: 'User'
},
title: {
type: String,
maxlength: 50
},
description: {
type: String
}
}, { timestamps: true}) '📂 Archive > Web Programming' 카테고리의 다른 글
| [Server] 터미널에서 npm run 하고 종료하는 법 + 프로세스 강제 종료 (0) | 2021.06.02 |
|---|---|
| [AWS] line 5: Bad configuration option: indentityfile, terminating, 1 bad configuration options 해결 (0) | 2021.05.28 |
| 인라인 코드블럭(인라인 코드 강조) 예쁘게 설정하기 (0) | 2021.05.11 |
| [HTML/CSS] 눈누 웹 폰트 HTML/CSS에 적용하기 (0) | 2021.02.04 |
| [HTML] HTML 문법 - 태그 (0) | 2021.01.14 |