ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • mongodb update, updateMany
    NoSql 2020. 9. 16. 16:45

    몽고 디비에 업데이트를 해야 해서 찾아본 상황을 적는다

     

    앞에는 조건 뒤에는 수정되어야할 값들

     

    db.getCollection('dbName').find({userId:2, useYN: 'Y'})-> 조건

     

    단일

    db.getCollection('dbName').update({userId:2, useYN: 'Y'}, {$set:{userId: '-2', useYN:'N'}})

     

    여러건

    db.getCollection('dbName').updateMany({userId:2, useYN: 'Y'}, {$set:{userId: '-2', useYN:'N'}})

     

    commit등은 따로 안해도 적용됨

     

    데이터 변경은 긴장된다.

    댓글

Designed by Tistory.