# loopback-component-mongodb-mt-automigrate

> Auto migrate with mongodb-mt connector

Latest version **2.1.0** (published 2020-04-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install loopback-component-mongodb-mt-automigrate
pnpm add loopback-component-mongodb-mt-automigrate
yarn add loopback-component-mongodb-mt-automigrate
bun add loopback-component-mongodb-mt-automigrate
```

## 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 | 2.1.0 |
| Published | 2020-04-01 |
| First published | 2018-06-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Fernando Franco |
| Maintainers | selfirius |
| Keywords | component, datasource, loopback, strongloop, mongodb-mt, multitenant |

## Links

- npm: https://www.npmjs.com/package/loopback-component-mongodb-mt-automigrate
- Repository: https://github.com/FernandoFranco/loopback-component-mongodb-mt-automigrate
- Homepage: https://github.com/FernandoFranco/loopback-component-mongodb-mt-automigrate#readme
- Issues: https://github.com/FernandoFranco/loopback-component-mongodb-mt-automigrate/issues
- npm.io page: https://npm.io/package/loopback-component-mongodb-mt-automigrate

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

- 2.1.0 (latest) — 2020-04-01
- 2.0.1 — 2020-04-01
- 2.0.0 — 2020-04-01
- 1.0.2 — 2018-06-20
- 1.0.1 — 2018-06-20
- 1.0.0 — 2018-06-20

## README

# loopback-component-mongodb-mt-automigrate
Auto migrate with mongodb-mt connector

## Instalation
Rum the command
`npm install loopback-component-mongodb-mt-automigrate`
or
´yarn add loopback-component-mongodb-mt-automigrate´

## Component configurations
Required configurations to using this component

### middleware.json
Need the loopback#token middleware in `./server/middleware.json`:
```json
{
  "routes:before": {
    "loopback#token": {
      "params": {
        "model": "MyAccessTokenModel"
      }
    }
  }
}
```
### model-config.json
Add Models in `./server/model-config.json`
```json
{
  "_meta": {
    "sources": [
      "../node_modules/loopback-component-mongodb-mt-automigrate/src/models"
    ]
  },
  "Automigrate": {
    "dataSource": "db",
    "public": false
  }
}
```
### component-config.json
Add `loopback-component-mongodb-mt-automigrate` in `./server/component-config.json`
```json
{
  "./component/automigration": {
    "method": "autoupdate",
    "dataSource": "db",
    "clustered": true,
    "models": [
      "MyModel",
    ]
  }
}
```
  * [method]: The method to automigration using:
     * `autoupdate`: Update the model indexes without change the database data.
     * `automigrate`: Migrate the model with cleaning the database data.
  * [dataSource]: The data source to using in the migration.
  * [models]: Models to migrate.

## Models configurations
Use in yours models the `version` and `indexes` attributes like this:
```json
{
  "name": "MyModel",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "indexes": {
    "idx_foo": {
      "keys": {
        "foo": 1
      }
    },
  },
  "options": {
    "validateUpsert": true
  },
  "version": 1,
  "properties": {
    "foo": {
      "type": "string",
      "required": true
    },
    "bar": {
      "type": "boolean",
      "default": true
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}
```

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