i'm trying to update the value of a field with the value of another field of a document. mongodb docs say it's possible by using an aggregation pipeline as described here.
even the sample code from the docs results in an TypeMismatch
code 14 error.
command:
db.members.update(
{ },
[
{ $set: { status: "Modified", comments: [ "$misc1", "$misc2" ] } },
{ $unset: [ "misc1", "misc2" ] }
],
{ multi: true }
)
result:
WriteCommandError({
"operationTime" : Timestamp(1561779602, 1),
"ok" : 0,
"errmsg" : "BSON field 'update.updates.u' is the wrong type 'array', expected type 'object'",
"code" : 14,
"codeName" : "TypeMismatch",
"$clusterTime" : {
"clusterTime" : Timestamp(1561779602, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
})
is this an actual bug in mongodb or am i missing something?