# mongo-to-csv

> mongoexport

Latest version **1.0.1** (published 2017-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongo-to-csv
pnpm add mongo-to-csv
yarn add mongo-to-csv
bun add mongo-to-csv
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-04-02 |
| First published | 2017-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yash Sharma |
| Maintainers | yasharma |
| Keywords | mongo |

## Links

- npm: https://www.npmjs.com/package/mongo-to-csv
- Repository: https://github.com/yasharma/mongo-to-csv
- Homepage: https://github.com/yasharma/mongo-to-csv#readme
- Issues: https://github.com/yasharma/mongo-to-csv/issues
- npm.io page: https://npm.io/package/mongo-to-csv

## Recent versions

- 1.0.1 (latest) — 2017-04-02
- 1.0.0 — 2017-04-02

## README

# mongo-to-csv [![Build Status](https://travis-ci.org/yasharma/mongo-to-csv.svg?branch=master)](https://travis-ci.org/yasharma/mongo-to-csv)
Export the mongodb collection to csv using mongoexport and nodejs

## Usage
```bash
1. $ npm install mongo-to-csv --save
```
```javascript
'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`](https://docs.mongodb.com/manual/reference/program/mongoexport/)command provided by mongodb and execute command through nodejs [`child_process`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)

#### 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
```

2. `cd mongo-to-csv`

3. `npm install`

4. `npm test`

---
_Source: https://npm.io/package/mongo-to-csv · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
