Notice
Recent Posts
Recent Comments
Link
아미(아름다운미소)
Node.js mongodb 드라이버 비동기 / 대기 쿼리 본문
const { MongoClient } = require('mongodb')
const MONGO_DB = 'mongodb://localhost:27017'
let db
try {
const client = await MongoClient.connect(MONGO_DB, { useNewUrlParser: true })
db = client.db('nodejsdb')
console.log("데이타베이스에 연결되었습니다. :" + MONGO_DB);
} catch (error) {
console.log(`
Mongo DB Host not found!
please add DB_HOST environment variable to .env file
exiting...
`)
process.exit(1)
}
'랭귀지 > NodeJS' 카테고리의 다른 글
[ UNIX-like OS]Error: listen EADDRINUSE: address already in use :::4000 (0) | 2020.05.03 |
---|---|
브라켓(Bracket) 멀티 탭 확장 모듈 설치 (0) | 2020.03.31 |
node.js (0) | 2020.03.19 |
Chocolatey 설치 (0) | 2020.01.08 |
라즈베리파이 Node.js 최신버전 설치 (2) | 2018.05.15 |
0 Comments