mongodb와 mongoose 연동 시 발생한 에러 제거 방법

 

npm uninstall mongoose ; npm install --save mongoose@5.10.7
// 기존에 설치된 mongoose 삭제 ; @ 뒤의 버전으로 mongoose를 재설치

최신 버전은 https://mongoosejs.com/ 아래의 링크를 확인한다.

 

Mongoose ODM v5.10.7

Let's face it, writing MongoDB validation, casting and business logic boilerplate is a drag. That's why we wrote Mongoose. const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost:27017/test', {useNewUrlParser: true, useUnifiedTopology:

mongoosejs.com

 

 

 

아래와 같이 기존에 사용하던 기능이 deprecated 되거나 port 관련 에러가 발생할 경우 mongoose.connect에 option을 부여한다.

mongoose.connect("mongodb://localhost:27017/yelp_camp", { useNewUrlParser: true, useUnifiedTopology: true});
// 27017은 mongodb에서 사용하는 port

 

 

(node:1159) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser,
 pass option { useNewUrlParser: true } to MongoClient.connect.
(node:1159) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. T
o use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

 

 

+ Recent posts