티스토리 뷰
1. 스키마(Schemas) 란 ?
데이터를 매핑하는데 사용되는 하나하나의 정보를 지정해 주는 역할을 합니다. 스키마에서 알 수 있는 정보는 데이터의 형식, 최소 길이, 최대 길이, 공백 등등 데이터의 정보를 알 수 있습니다.
const userSchema = mongoose.Schema({
name :{
type : String,
maxlength : 50
},
email : {
type: String,
trim: true,
unique :1
},
password : {
type: String,
maxlength : 70
},
lastname : {
type: String,
maxlength:50
},
role : {
type : Number,
default : 0
},
image : String,
token : {
type: String
},
//토큰을 이용해서 유효성을 관리
tokenExp : {
type : Number
}
//유효기간, 토큰이 사용할 수 있는 기간을 주는 것
})
2. Model 이란 ?
스키마를 감싸는 역할을 합니다.
index.js 에서 사용할 수 있게 export 시켜줍니다.
const User = mongoose.model('User', userSchema )
module.exports = {User}
https://mongoosejs.com/docs/guide.html#schemas
Mongoose v6.9.0: Schemas
If you haven't yet done so, please take a minute to read the quickstart to get an idea of how Mongoose works. If you are migrating from 5.x to 6.x please take a moment to read the migration guide. Everything in Mongoose starts with a Schema. Each schema ma
mongoosejs.com
DB , 데이터 베이스 누군가 얘기했을 때 알아 들을 수 있게 개념은 알아두도록 하자!
'프론트엔드 > javaScript, jQuery' 카테고리의 다른 글
| 자바스크립트 개념 정리 (0) | 2024.10.28 |
|---|---|
| [jQuery] slick-slide Paging Custom (Counter 표시하기) (0) | 2023.06.29 |
| [jQuery, javaScript] 팝업창 제외 배경 선택 시 팝업 닫기 (0) | 2022.04.12 |
| [jQuery] 소수점 기준 자리수 체크 (0) | 2022.04.12 |
| [javaScript] setTimeOut() (0) | 2021.12.23 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- node.js
- excel down
- npm
- 디자인시스템만들기
- frontend
- excel custom
- react portal
- 리액트 포탈
- 탭메뉴
- css3
- Portal
- react excel 다운
- CSS
- 퍼블리셔
- jQuery
- slick-slide
- paging-custom
- 개발
- 페이징 커스텀
- 프론트엔드개발
- 퍼블리싱
- HTML
- 프론트엔드
- react
- javascript
- 로그인폼
- 슬릭 슬라이드
- 제이쿼리
- file-saver
- React.js
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
글 보관함