# mongoose-unique-params-plugin

> This plugin adds a static function that analyzes the model and allows you to get a list of schema keys(or paths) that are unique

Latest version **1.1.0** (published 2018-07-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-unique-params-plugin
pnpm add mongoose-unique-params-plugin
yarn add mongoose-unique-params-plugin
bun add mongoose-unique-params-plugin
```

## 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.0 |
| Published | 2018-07-13 |
| First published | 2018-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nikolay Lapshin |
| Maintainers | nlapshin |

## Links

- npm: https://www.npmjs.com/package/mongoose-unique-params-plugin
- Repository: https://github.com/nlapshin/mongoose-unique-params-plugin
- Homepage: https://github.com/nlapshin/mongoose-unique-params-plugin#readme
- Issues: https://github.com/nlapshin/mongoose-unique-params-plugin/issues
- npm.io page: https://npm.io/package/mongoose-unique-params-plugin

## Dependencies (3)

- [flat](https://npm.io/package/flat.md) ^4.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [object-deep-iteration](https://npm.io/package/object-deep-iteration.md) ^1.0.0

## Recent versions

- 1.1.0 (latest) — 2018-07-13
- 1.0.0 — 2018-07-13

## README

# mongoose-unique-params-plugin

This plugin adds a static function that analyzes the model and allows you to get a list of keys that are unique

# Install

```sh
npm i mongoose-unique-params-plugin
```

# Usage

```js

const plugin = require("mongoose-unique-params-plugin");

let schema = new mongoose.Schema({
    name: { type: String, unique: true },
    title: { type: String},
    flags: {
    	checked: { type: Boolean, unique: true }
    }
});

schema.plugin(plugin);

let model = mongoose.model("test", schema);

console.log(model.uniqueParams()) // { name: true, flags: { checked: true } }

console.log(model.uniqueParams(true)) // { name: true, flags.checked: true }

```

# API

model.uniqueParams(flatten).

*flatten* - option that allows you to expand an object. Optional. Default false.

# License

MIT © nlapshin

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