I am trying to perform several insertions on an existent Mongo DB collection using the following code
db.dados_meteo.aggregate( [
{ $match
The short answer is "you can't":
If the collection specified by the $out operation already exists, then upon completion of the aggregation, the $out stage atomically replaces the existing collection with the new results collection. The $out operation does not change any indexes that existed on the previous collection. If the aggregation fails, the $out operation makes no changes to the pre-existing collection.
As a workaround, you can copy the collection document specified by $out to a "permanent" collection just after aggregation, in one of a several ways (non of which is ideal though):
db.out.find().forEach(function(doc) {db.target.insert(doc)})