I'm trying to export a result from an aggregating pipeline into a CSV file.
The aggregation need {allowDiskUse: true}
, here through a view :
db.myView.aggregate([], {allowDiskUse: true})
I use the mongoexport
command to export the result into a CSV file :
mongoexport --uri "mongodb+srv://[**HOST**]" --authentivationDatabase admin -d myDb -c myView --type=csv --out "C:/path/extract.csv" --fields "id"
2022-09-05T14:59:57.425+0200 connected to: mongodb+srv://[**HOST**]
2022-09-05T14:59:58.503+0200 myDb.myView 0
2022-09-05T14:59:59.504+0200 myDb.myView 0
...
2022-09-05T15:01:35.515+0200 myDb.myView 0
2022-09-05T15:01:36.434+0200 myDb.myView 0
2022-09-05T15:01:36.434+0200 Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUser to upt in.
mongoexport doesn't seem to have allowDiskUse
option.
Is there a way to extract the result from the aggregation pipeline into a CSV file ?