# mongoose-json-patch-history

> A Mongoose Plugin which stores changes in json-patch format

Latest version **1.0.2** (published 2016-03-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongoose-json-patch-history
pnpm add mongoose-json-patch-history
yarn add mongoose-json-patch-history
bun add mongoose-json-patch-history
```

## 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.2 |
| Published | 2016-03-30 |
| First published | 2016-03-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+8 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Max Joehnk |
| Maintainers | maxjoehnk |
| Keywords | mongoose, jsonpatch, json-patch, history, log, mongodb, mongo |

## Links

- npm: https://www.npmjs.com/package/mongoose-json-patch-history
- Repository: https://github.com/maxjoehnk/mongoose-json-patch-history
- Homepage: https://github.com/maxjoehnk/mongoose-json-patch-history#readme
- Issues: https://github.com/maxjoehnk/mongoose-json-patch-history/issues
- npm.io page: https://npm.io/package/mongoose-json-patch-history

## Dependencies (2)

- [mongoose](https://npm.io/package/mongoose.md) ^4.4.10
- [fast-json-patch](https://npm.io/package/fast-json-patch.md) ^0.5.6

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

- 1.0.2 (latest) — 2016-03-30
- 1.0.1 — 2016-03-30
- 1.0.0 — 2016-03-30

## README

# mongoose-json-patch-history

This plugin saves a history of all changes in the json-patch format

## Installation
```bash
npm install mongoose-json-patch-history --save
```

## Usage
```javascript
const mongoose = require('mongoose');
const history = require('mongoose-json-patch-history');

var schema = mongoose.Schema({
  name: String,
  ...
});

schema.use(history);
```

## API
### document#history()
#### store(): Promise\<IHistory>
Stores a new history entry.
Note: This gets called on pre save hook

#### retrieve(): Promise\<IHistory[]>
Returns all history entries for this document

#### clear(): Promise\<>
Clears the History of this document

### document#patch(patches: [], save?: boolean)
Applies the patches and saves the modified document.

### document#$history: mongoose.Model\<IHistory>
The History Collection for the current model

## Options
| Option    | Type               | Default Value                                           | Description   |
|-----------|--------------------|---------------------------------------------------------|---------------|
| database  | [Mongoose Connection](http://mongoosejs.com/docs/api.html#connection_Connection) | `mongoose` | The Database the document should connect to |

## TODO:
 * configurable collection names

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