개발/Error note
[MongoDB error] MongoParseError: options usecreateindex, usefindandmodify are no
이나당
2022. 8. 19. 10:29
const mongoose = require('mongoose');
mongoose
.connect('mongodb+srv://inadang:<비번>@inadang.layhnvt.mongodb.net/?retryWrites=true&w=majority', {
useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false
})
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));

MongoParseError: options usecreateindex, usefindandmodify are not supported
몽고디비 6 이상부터는 use...를 지원하지않는다. 그래서 {}안에 모두 지워줬다.
지우고나니
MongoServerError: bad auth : Authentication failed.
에러가 떴는데 이건 비밀번호 <>를 지우지 않아서 생긴 실수.
const mongoose = require('mongoose');
mongoose
.connect('mongodb+srv://inadang:비번&@inadang.layhnvt.mongodb.net/?retryWrites=true&w=majority', {})
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));

예쁘게 연결됐다!
반응형