파크로그
[MongoDB] collections에 필드 생성 및 삭제
Backend/🛢 DataBase 2020. 12. 22. 20:16

- 기존에 쓰고있던 collections ( Post - 게시글 데이터베이스 ) 에서, 게시글을 각각 지우는 것은 로직 비용이 크기에, isDeleted 컬럼을 추가하여 사용여부를 판단하기로 결정하였다. mongoDB로 기존에 쓰고있던 collections에 어떻게 field를 추가할까? > db.posts.update({}, {$set: {isDelete:false}}, false, true) WriteResult({ "nMatched" : 4, "nUpserted" : 0, "nModified" : 4 }) > db.posts.update({}, {$unset: {isDelete:false}}, false, true) WriteResult({ "nMatched" : 4, "nUpserted" : 0,..