mongo-to-csv

mongoexport

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
mongo-to-csv
031.0.16 years ago6 years agoMinified + gzip package size for mongo-to-csv in KB

Readme

mongo-to-csv Build Status
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 mongoexportcommand 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

  1. clone the repo
```bash $ git cone https://github.com/yasharma/mongo-to-csv.git ```
  1. cd mongo-to-csv

  1. npm install

  1. npm test