I'm back to our pipeline we built earlier, you'll find it attached to this video.
This pipeline here will return us persons in a restructured form where we also have the location.
Now if you want to use that location, we can do that inside of our pipeline here,
we do actually have a pipeline stage
for working with geo data but that has to always come first in order to take advantage of indexes.
Now what can we do?
Well the good thing is you can also take the result of a pipeline and write it into a new collection,
of course not just if you have geo data in there, you can always do that. For that you do specify another
pipeline stage, the $out stage for output and this will take the result of your operation
and write it into a collection, either a new one which is created on the fly or an existing one. I'll name
this transformed persons,
so I only added this stage. If I now copy that and I run it without pretty at the end by the way
but it should have still worked,
you see I have my transformed persons there. And if I look into transformed persons, you see the structure
in there is exactly the structure we created in the last pipeline.
So the out operator is great if you have a pipeline where you want to funnel your results right into
a new collection,
often you want to use it and just fetch it
but if you need to store it, you can do that with the out stage.