# mongodb-io-native

> export & import mongodb documents

Latest version **0.1.2** (published 2017-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongodb-io-native
pnpm add mongodb-io-native
yarn add mongodb-io-native
bun add mongodb-io-native
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2017-06-09 |
| First published | 2017-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrey Yartsev |
| Maintainers | andrey-yartsev |
| Keywords | mongodb, mongodump, mongorestore |

## Links

- npm: https://www.npmjs.com/package/mongodb-io-native
- Repository: https://github.com/majexa/mongodb-io-native
- Issues: https://github.com/majexa/mongodb-io-native/issues
- npm.io page: https://npm.io/package/mongodb-io-native

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2017-06-09
- 0.1.1 — 2017-06-08
- 0.1.0 — 2017-06-08

## README

[![NPM version](https://img.shields.io/npm/v/mongodb-io.svg)](https://www.npmjs.com/package/mongodb-io) [![Downloads](https://img.shields.io/npm/dm/mongodb-io.svg)](http://badge.fury.io/js/mongodb-io)

Original mongodb-io exports empty databases on Ubuntu server. So I replaced 
mongodump-linux, mongorestore-linux tools with native mongo ones. So mongodb is
required to install now.

Fork made for [mongo-export server](http://github.com/majexa/mongo-export) & [mongo-import](http://github.com/majexa/mongo-import) tool.

# mongodb-io-native
export & import mongodb documents, base on `mongodump` and `mongorestore`.

## Required

Mongo installed (with mongodump, mongorestore utils)

## Support

only for linux x64 and OS X x64.

## Usage

```
import DBIO from 'mongodb-io';
```

#### config

The second argument in `DBIO.export` or `DBIO.import`, params and default value seems like:

```
{
  host: 127.0.0.1,
  port: 27017,
  user,
  password,
  out: 'dump', // export filename
  drop: false, // Before restoring the collections from the dumped backup, drops the collections from the target database.
  filePath: '' // path to read `tar.gz` file for mongorestore.
}
```

#### export

```
var filePath = await DBIO.export({config, dbs}); // this is a `tar.gz` file
```

if `dbs` is not a array, will export all dbs. `dbs` is seems like:

```
['dbName1', {name: 'dbName2', collections}, ...]
``` 
the array of database names, or database settings you want to export.

`collections` is seems like:

```
['collectionName1', {name: 'collectionName2', query: '{_id: 111}'}, ...]
```

the array of collection names, or collection settings you want to export.

#### import

```
await DBIO.import({config, dbs});
```

In each item of dbs or collections you could set `drop`, like that item in config.

#### errors

```
Error: {name: 'DBIO_XXX_ERR', message: 'where error happend'}
```

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