How to use mongoexport in count? I want to get the count of all rows in a single collection into an output file. What is the correct way of doing this
Here is what I did but I am encountering an error.
mongoexport --host 10.1.0.1:27017 --db proddb --collection  UserColl --query &quot;{db.getCollection('UserColl').count()}&quot; --type=csv --out=output.csv
I created a sample.js file like the sample below:
db=db.getSiblingDB('DbName');

printjson( db.getCollection('CollectionName').find().count() );

then I run this script below on cmd:
mongo --host IP:PORT --username username --password password --authenticationDatabase admin --quiet sample.js &gt; sample.csv