# translate-mongodb-documents

> Translate mongodb documents.

Latest version **1.1.2** (published 2017-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install translate-mongodb-documents
pnpm add translate-mongodb-documents
yarn add translate-mongodb-documents
bun add translate-mongodb-documents
```

## 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.1.2 |
| Published | 2017-10-17 |
| First published | 2017-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.4.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ernesto Rojas |
| Maintainers | ernestojr |

## Links

- npm: https://www.npmjs.com/package/translate-mongodb-documents
- Repository: https://github.com/ernestojr/translate-mongodb-documents
- Homepage: https://github.com/ernestojr/translate-mongodb-documents#readme
- Issues: https://github.com/ernestojr/translate-mongodb-documents/issues
- npm.io page: https://npm.io/package/translate-mongodb-documents

## Dependencies (1)

- [mongoose](https://npm.io/package/mongoose.md) ^4.12.1

## Recent versions

- 1.1.2 (latest) — 2017-10-17
- 1.1.1 — 2017-10-15

## README

# Translate mongodb documents

This module allows to cover the documents of a collection, based on a model A, to another model B. This module uses `mongoose` for data models.
This module uses the `async` and` await` instructions of ES2017. We recommend using node version `v8.4.0`.
Installation:

```
npm i -S translate-mongodb-documents
```
Here's an example of use:

```javascript
const Translate = require('translate-mongodb-documents')
const sC1 = process.env.MONGODB_URI_ORIGIN
const sC2 = process.env.MONGODB_URI_FINAL
const userSchema = {
  firstName: { type: String },
  lastName: { type: String },
  address: { type: mongoose.Schema.Types.Mixed },
  createdAt: { type: Date, default: Date.now }
}
const simpleUserSchema = {
  fullName: { type: String },
  address: { type: mongoose.Schema.Types.Mixed },
  createdAt: { type: Date }
}
function translate(doc) {
  const { address, createdAt } = doc
  return { fullName: `${doc.firstName} ${doc.lastName}`, address, createdAt }
}
const models = [
  [
    {
      name: 'User',
      collectionName: 'user',
      schema: userSchema,
      criteria: {}
    },
    {
      name: 'SimpleUser',
      collectionName: 'simpleUser',
      schema: simpleUserSchema,
      translate
    }
  ]
]
(async () => {
    const iTranslate = new Translate(sC1, sC2, models)
    console.log(await iTranslate.start())
})().catch(err => console.error(err))
```

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