Let's go back to our flight data, let's quickly find all the flights here,
this is our flight data
and now let's say we want to store the status for a flight. For this, I'll use my flight data and I'll update
many elements,
I'll pass an empty document as a filter to target them all
and then here, we have $set
and then how we want to change them
and now let's say we want to add a status field but that status is not something like on time which
you could use
but let's say this is another document.
So here another pair of curly braces,
so this is now a value we set for status which we add to our flight data.
And now here you can enter anything which you can have in a document, multiple key value pairs, even
other nested documents if you want.
So here we could have a description field which is on time and maybe last updated which is one hour ago,
if we now hit enter here,
it updated both documents because we had no filter
and if I now output my flight data in a pretty way, we see these nested documents here and this is what's
called embedded document,
I use nested and embedded interchangeably here.
So this is an embedded document,
it's another json document within a wrapping json document.
We got two documents in the collection and each of these documents has a child document
and as I said, inside of the status, you could have another nested document.
So if I would repeat my command here and add another value with maybe details, that could be another
nested document, so another pair of curly braces, maybe this has a responsible field and there, I put my name
in there.
If I now hit enter and I output all the flights again,
now we see another nested document in there,
so a nested document or an embedded document in an embedded document in a collection document.
So these are embedded documents
and now we also can have arrays of data.
Let's have a look at that in the next lecture.