Now before we continue with other operators, one more word about $set,
I only used it to change one field at a time.
Now Chris can still need some work,
we can add a phone number and an age,
so again I will take the objectId of Chris and then I will use update one again
and of course by the way, I could also use update many even if I know only one document will be affected
but update one is clearer about my intention
and since I filter for the ID,
it's pretty clear that there will be only one document that matches.
So I filter for Chris here essentially and I use $set again to describe the changes to that document
and now here, I will actually change multiple fields, so I will set the age to let's say 40 and I will
set the phone number to some random number, like this. If I now hit enter,
you'll see again
we found one document, we updated one document,
if I have a look at all my documents, you see age and phone was added to Chris now.
So $set is of course not limited to updating only one field,
it can update as much as you want on the document.
It can add arrays as you saw previously with the hobbies array,
it can add embedded documents as you saw with documents in the array,
of course it can also add embedded documents outside of arrays,
so it gives you the full flexibility
you also have in your inserting documents, just that it either adds a field or simply, well edits it.