here is the document names “seasonrank”:
{
"_id" : ObjectId("655f1d9fb20a2c9cd6af7a38"),
"playerid" : "5e16a6aa-dea5-48ab-b0cf-805378d97d34",
"channel" : "android",
"logintime" : 1700043180,
"ranklevel" : 100,
"lastscore" : "0",
"rankname" : "",
"tasks" : [
210007
],
"level" : 13,
"score" : 10,
"task" : [
],
"taskprocess" : {
"count" : 0,
"getlist" : null
}
}
When I run the command in MongoDB versions below 4.0
db.getCollection(‘seasonrank’).updateMany(
{},
[{“$set”: {“lastscore”: “$score”}}]
)
it will be ok ,however when this commands run at 4.0.2 or higher version will receieve an error:
{
"ok" : 0.0,
"errmsg" : "BSON field 'update.updates.u' is the wrong type 'array', expected type 'object'",
"code" : 14.0,
"codeName" : "TypeMismatch"
}
how to solve, anyone who can help me ? regards!