There is this MongoDB Document:
{
"name": "First Floor",
"years": {
"Year 1": {
"Class A": [
"Nayara",
"Steve",
"Jean"
],
"Class B": [
"Mark",
"James",
"Ana"
]
}
}
}
Is there a way to update the array key name, the “Year 1” to “Year somethingelse”?
If so, could it also be used with the “Class A” and “Class B” to change it to “Class somethingelse”?
Yes, you should $rename
You can do the same with “Class A” and “Class B” fields, of course.