결론적으로 mongoose.set("strictQuery", false //또는 true) 코드를 추가하면 해결된다.
원인 : 몽구스 7 버전에서는 strictQuery 값이 기본적으로 true다.
그런데 현재 나의 몽구스 버전은 6버전으로 strictQuery 값을 지정해 둬야 버전이 바뀌었을 때 예상하지 못한 오류를 방지하기 위해 이러한 오류가 나타나는 것이다.
// 코드 추가
const mongoose = require("mongoose");
const connect = () => {
mongoose
.connect("mongodb://127.0.0.1:27017/sparta_db")
.catch(err => console.log(err));
};
mongoose.set("strictQuery", false) // 추가한 코드
mongoose.connection.on("error", err => {
console.error("몽고디비 연결 에러", err);
});
module.exports = connect;
'내일배움캠프 노드 4기 > Today I Learned' 카테고리의 다른 글
22/12/15 TIL - MongoDB → mongoose (0) | 2022.12.15 |
---|---|
22/12/14 TIL - Package Manager, Express.js (0) | 2022.12.15 |
22/12/12 TIL - Node.js, 노드 문법 (0) | 2022.12.12 |
22년 12월 08일 TIL (0) | 2022.12.09 |
22년 12월 07일 TIL (0) | 2022.12.07 |