mongo-to-csv

1.0.1 • Public • Published

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
$ git cone https://github.com/yasharma/mongo-to-csv.git
  1. cd mongo-to-csv

  2. npm install

  3. npm test

Readme

Keywords

Package Sidebar

Install

npm i mongo-to-csv

Weekly Downloads

50

Version

1.0.1

License

MIT

Last publish

Collaborators

  • yasharma