我知道我能做到使用$set
更新:如何在MongoDB中/貓鼬使用其以前的值更新字段
Contact.update({
_id: request.id
}, {
$set: { name: newNameValue }
}, {
upsert: false
}, function(err) { ... });
但在這種情況下,強似newNameValue
,我想用之前的name
值來計算新的值。比方說,我想大寫舊名稱,如:
Contact.update({
_id: request.id
}, {
$set: { name: $old.name.toUpperCase() }
}, {
upsert: false
}, function(err) { ... });
這很可能是無法實現的一個語句來做到這一點。 – Mikey