인프런 노드 리액트 강의를 보며 몽구스 사용하다 생긴 오류
const mongoose = require('mongoose')
mongoose.connect('~my connect string~',{
useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false
}).then(()=>console.log('MongoDB Connected....'))
.catch((err)=>console.error(err))
index.js에 위 코드를 추가하니
MongoParseError: options usecreateindex, usefindandmodify are not supported
이와 같은 오류 메시지가 뜨며 몽고디비와 커넥트가 되지 않았다.
구글링하다가
https://www.mongodb.com/community/forums/t/option-usecreateindex-is-not-supported/123048
Option usecreateindex is not supported
I am trying to connect mongoDB to my web app but it is saying that usercreateindex is not supported please help me with this This is the code from my index.js file const express = require('express'); const app = express(); const mongoose = require('mongoos
www.mongodb.com
같은 문제에 대한 질문을 올린 글을 발견하게 되었고, 그 글에 달린 댓글에 의하면....
그렇다고 한다....
몽고디비 6버전에서는 useCreateIndex 옵션이 deprecated라고..더 이상 사용하지 않는단다.
그 외에 내가 위에 옵션으로 추가했던 useNewUrlParser, useUnifiedTopology, userCreateIndex는 항상 true 값으로 실행되고 useFindAndModify는 false 값으로 이용된다고...
강의를 들을 때 위 옵션을 추가하지 않으면 에러가 뜰 수 있다고 했는데..앞에 돌려보니 강의 시점 mongoose 버전이 5버전이었다.
그래서 결국 커넥트 할 때 넣었던 옵션 부분을 뺐더니 커넥트 성공!
'Node.js' 카테고리의 다른 글
[Node.js] 프로젝트 서버 heroku에 배포하기-github 연동 (0) | 2022.06.29 |
---|---|
[Node.js] jwt에러 Error: Expected "payload" to be a plain object. (0) | 2022.04.05 |
[Node.js] body-parser (0) | 2022.04.05 |
[Node.js] mysql, sequelize 데이터베이스 세팅 (0) | 2022.03.25 |
[Node.js] 폴더 구조 정리 (0) | 2022.03.24 |