mongo-to-csv
v1.0.1
Published
mongoexport
Downloads
135
Readme
mongo-to-csv
Export the mongodb collection to csv using mongoexport and nodejs
Usage
1. $ npm install mongo-to-csv --save
'use strict';
const mongotocsv = require('mongo-to-csv');
let options = {
database: 'users', // required
collection: 'pets', // required
fields: ['name','cost'], // required
output: './output/pets.csv', // required
allValidOptions: '-q \'{ "name": "cat" }\'' // optional
};
mongotocsv.export(options, function (err, success) {
console.log(err);
console.log(success);
});
This libaray uses the mongoexport
command provided by mongodb and execute command through nodejs child_process
you can pass all the available options of mongoexport command here through allValidOptions
property.
Run test
- clone the repo
$ git cone https://github.com/yasharma/mongo-to-csv.git
cd mongo-to-csv
npm install
npm test