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
npm i mongoose-unique-params-plugin
Usage
const plugin = ; let schema = name: type: String unique: true title: type: String flags: checked: type: Boolean unique: true ; schema; let model = mongoose; console // { name: true, flags: { checked: true } } console // { name: true, flags.checked: true }
API
model.uniqueParams(flatten).
flatten - option that allows you to expand an object. Optional. Default false.
License
MIT © nlapshin