# mersion

> Retry Mongoose saves that suffer from conflicts via VersionErrors

Latest version **0.0.2** (published 2020-10-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install mersion
pnpm add mersion
yarn add mersion
bun add mersion
```

## 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.0.2 |
| Published | 2020-10-13 |
| First published | 2018-08-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sean Lavine |
| Maintainers | freewil |
| Keywords | mongoose, version, VersionError, save, save, conflict, retry |

## Links

- npm: https://www.npmjs.com/package/mersion
- Repository: https://github.com/hellodigit/mersion
- Homepage: https://github.com/hellodigit/mersion#readme
- Issues: https://github.com/hellodigit/mersion/issues
- npm.io page: https://npm.io/package/mersion

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^3.1.0

## 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.0.2 (latest) — 2020-10-13
- 0.0.1 — 2018-08-19
- 0.0.0 — 2018-08-19

## README

# mersion

Retry Mongoose saves that suffer from conflicts via VersionErrors

```js
const mongoose = require('mongoose')
const Mersion = require('mersion')

const Book = mongoose.model('Book', new Schema({
  title: String,
  tags: [String]
}))

(async () => {
  const mersion = new Mersion({
    loadFn: () => Book.findById(bookId),
    saveFn: (book) => {
      // mutating array has the possibility of causing a VersionError
      book.tags = ['fiction']
      return book.save()
    },
    retries: 2
  })

  // Calls `loadFn`, followed by `saveFn()`.
  // If a VersionError occurs, will retry `retries` times
  const savedBook = await mersion.save()
})()
```

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