mongoose-draft
Mongoose draft plugin to disable the model validation
Installation
Install via npm:
$ npm install mongoose-draft
Documentation
Options
isDraft
set the initial value (optional, defaulttrue
)fieldName
set fieldName value, use it only is you're already using the default value somewhere else (optional, default_is_draft
)
Methods
instance.setIsDraft(isDraft)
Set the value of isDraft
Virtual fields
instance.isDraft
Get/Set the value of isDraft
Examples
var mongoose = ;var draft = ; var TestSchema = 'label_1': 'type': String 'required': true 'label_2': 'type': String 'required': false ; TestSchema; var TestDraft = mongoose; var model = model; // -> return a promise fulfilled without any validation errorsmodelisDraft = false;model; // -> return a promise fulfilled with validation errors model; model; // -> return a promise fulfilled with the model instancemodel;model; // -> return a promise fulfilled with validation errors
Contributing
This project is a work in progress and subject to API changes, please feel free to contribute