I am able to sort data in compass, but my problem is when I export, I don't get it sorted and I can't find where can I apply sort upon exporting data?
As you can see here I am filtering with {name: 'SelectedProduct'}
and I am sorting with {name: 1}
:
But in the export collection dialog for the same filter and sort as above image, I see this:
I can't seem to find how can I apply sort on exported data.
Even I am facing similar issue. If you see in the Query window in 1st screen you have got only 1 document where as in Export data window it is showing 984 records. This is a bug which needs to be fixed by MongoDB Compass. Export behaves like a "Entire Full Collection" & there is no impact of Query that is written.
I also needed that.
Go to Aggregations and choose $sort.
Past your sort:
{
name: 1
}
Save as Create a view.
Then you just need to go to that view and it will be sorted and ready to export.
I found a solution (detour) to compass bug: steps:
Also if you want to do the same procedure through the shell this is the command: db.videos.aggregate([{$match:{hasError: {$ne: true},videos:{$gt:[]},businessAuth: {$in: [ObjectId('5f78a94323614f0020554f96')]}}},{ $out : "heavy" }])
explain:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With