We saw how we can insert, update and delete things in the last lecture and therefore our flight data are
now is empty as we can confirm if we run find, nothing is returned.
Now time to add something again
and there was this file you found attached earlier,
you can find it attached again to this lecture.
It holds an array of json documents and now I want to use the entire array,
so make sure to copy the entire file content and then back in the shell,
let's again access our flight data and use insertMany now. insertMany now allows you well as the name suggests,
to insert many elements and this is actually not done by adding many elements separated by commas but
instead by passing an array,
so exactly the kind of data we got.
Let's delete the closing parentheses and paste that in
and then add the closing parentheses after the closing square brackets. And with that if you now hit enter,
you see
this was accepted and it inserted two IDs
and there you also see this order,
it automatically keeps which I mentioned. It's almost the same ID but the second ID has a c at the
end and therefore, it will be ordered after the first element which makes sense because it was the second
element inserted
so mongodb keeps the order here. And now if we again access our flight data and find it all and pretty
print it,
here is our flight data with the automatically added IDs.
So this is now insertMany and now you saw both, insertOne and insertMany,
you also saw updateOne and updateMany and deleteOne and deleteMany.
There is another thing I want to show you though and that is related to finding data.