我有一组 mongo 文档,我需要转换/更新以下值,例如 ("workedDate" : ISODate("2020-07-01T00:00:00Z"))
"workedDate" : ISODate("2020-07-01T20:03:04Z"),
"workedDate" : ISODate("2020-07-01T19:59:07Z"),
"workedDate" : ISODate("2020-06-30T14:00:00Z"),
"workedDate" : ISODate("2020-07-01T19:49:29Z")
我尝试了以下查询:
db.timeentrys.update(
{ },
{
$set: {
workedDate:{$dateFromParts:{
year:{$year:"$workedDate"},
month:{$month:"$workedDate"},
day:{$dayOfMonth:"$workedDate"}
}}
}
}
)
收到以下错误:
WriteResult({
"nMatched" : 0,
"nUpserted" : 0,
"nModified" : 0,
"writeError" : {
"code" : 52,
"errmsg" : "The dollar ($) prefixed field '$dateFromParts' in 'workedDate.$dateFromParts' is not valid for storage."
}
})