-
카테고리
-
세부 분야
풀스택
-
해결 여부
미해결
update
21.02.10 01:53 작성 조회수 85
0
Product모델에서 그럼 findoneandupdate가 아니라 update를 쓴이유도 async 덕분이라고 보면 될까요?
async.eachSeries(products,(item, callback) =>{
Product.update(
{_id: item.id},
{
$inc: {
"sold" : item.quantity
}
},
{new: false},
callback
)
}
답변을 작성해보세요.
0
John Ahn
지식공유자2021.02.10
안녕하세요 !! 아뇨 update과 findOneAndUpdate 모두 몽구스 메소드 입니다.
비슷한 기능이지만 update은 여러개의 Documents를 한번에 업데이트할 수 있으며 , findOneAndUpdate은 필터 조건에 걸리는 첫번째 Document를 업데이트하는 차이가 있습니다!
답변 1