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판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
222
한 권으로 끝내는 Node & Express
추가합니다.
“mongo”: {
“connectionString”: “your_dev_connection_string”
}
연결 문자열
connection
string
mLab
의 데이터베이스 페이지에서 찾을 수 있습니다. 홈 화면에서
데이터베이스를 클릭하면
mongodb
://
로 시작하는 몽고
DB
연결
URI
를 볼 수 있습니다. 사용
자도 만들어야 합니다. [
Users
]를 클릭하고 [
Add
database
user
]를 클릭합니다.
8
.
credentials
.
production
.
js
파일을 만들고
NODE
_
ENV
=
production
을 사용하면 실무에
쓸 두 번째 자격 증명을 만들 수 있습니다. 실무로 전환할 때 이 작업이 필요합니다.
설정을 마쳤으니 이제 실제로 데이터베이스에 연결하고 뭔가 유용한 일을 해봅시다.
13.3.5
몽구스로 데이터베이스에 연결
9
먼저 데이터베이스에 연결합니다. 데이터베이스 초기화 코드를 앞에서 만든 더미
API
와 함께
db
.
js
에 넣습니다 (
ch13
/
00
-
mongodb
/
db
.
js
).
const mongoose = require(‘mongoose’)
const { connectionString } = credentials.mongo
if(!connectionString) {
console.error(‘MongoDB ...
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