Skip to Content
한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
book

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

by 한선용, 이선 브라운
May 2021
Beginner to intermediate
448 pages
9h 47m
Korean
Hanbit Media, Inc.
Content preview from 한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
223
13
지속성
console.error(‘MongoDB error: ‘ + err.message)
process.exit(1)
})
db.once(‘open’, () => console.log(‘MongoDB connection established’))
module.exports = {
getVacations: async () => {
//...return fake vacation data
},
addVacationInSeasonListener: async (email, sku) => {
//...do nothing
},
}
데이터베이스에 접근해야 하는 파일이 있으면
db
.
js
를 임포트하기만 하면 됩니다.
API
가 필
요해지기 전에 먼저 초기화를 해야 하니
meadowlark
.
js
에서 임포트합니다(이 파일에는
API
가 필요하지 않습니다).
require(‘./db’)
이제 데이터베이스와 연결되었으니 데이터베이스와 주고받을 데이터를 어떤 구조로 만들지 생
각해봅시다.
13.3.6
스키마와 모델 만들기
메도라크 여행사에서 사용할 휴가 패키지 데이터베이스를 만들어봅시다. 먼저 스키마를 정의
하고, 그 스키마에서 모델을 만듭니다.
models
/
vacation
.
js
파일을 만듭니다 (
ch13
/
00
-
mongodb
/
models
/
vacation
.
js
).
const mongoose ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한성용, 이선 브라운

Publisher Resources

ISBN: 9791162244227