1
我想使用mongoose的findByIdAndUpdate方法傳入對象標識列表並一次更新它們。但是,我收到「錯誤:無法使用ObjectId設置$。」錯誤,我似乎無法與我的代碼相關聯。通過傳遞列表objectids更新多個文檔findByIdAndUpdate
這是我的代碼。
return ComponentModel.findByIdAndUpdate({
_id: {
$in: input.subjectIds
},
$set: { location: input.newLocation }
}).then(res => res);