LearnBoost/mongoose — Issue #730: Saving document when selecting specific fields fails.
Author: azampagl
Created: 2012-02-12 05:46:14+00:00
State: open

Saving a document that was loaded with a specific set of fields fails if a required field was left out.

eg.

User.findById(_id, ['_id', 'email', 'locale', function(err, user) { ... });

Now there is a document (user) with only those particular fields. Upon saving, validation errors occur for fields that are required, but weren't loaded (say I have a required password field, but didn't want to load it).

I was hoping this was possible based on your comments in the api "we can determine the MINIMUM set of dirty data that we want to send to MongoDB on a Document save." Is there any way to get the save to transparently ignore required fields if they weren't loaded in the first place?