I am trying to perform several insertions on an existent Mongo DB collection using the following code
db.dados_meteo.aggregate( [
{ $match
It's not the prettiest thing ever, but as another alternative syntax (from a post-processing archive/append operation)...
db.targetCollection.insertMany(db.runCommand(
{
aggregate: "sourceCollection",
pipeline:
[
{ $skip: 0 },
{ $limit: 5 },
{
$project:
{
myObject: "$$ROOT",
processedDate: { $add: [new ISODate(), 0] }
}
}
]
}).result)
I'm not sure how this stacks up against the forEach variant, but i find it more intuitive to read.