npm i exportmongodatabase
const exportDb = require('exportmongodatabase');
exportDb.exportDataBase("mongodb://localhost:27017/PMS");
example : "mongodb://localhost:27017/PMS"
example : "mongodb://username:password@host:port/dbname"
This will create a folder of database in your project folder name and all the collections will be exported by there name in csv file.