LearnBoost/mongoose — pull request #933 by treygriffith (2012-05-23 18:22:05+00:00)
Title: Update from a Document

These changes allow you to pass an instance of a Document as the update argument for both `update` and `findOneAndUpdate`.

This is useful in scenarios where you might be upserting a document but want to make sure that it adheres to your schema (especially adding default values) in the case that it is a new document.

Especially with the new `findOneAndUpdate` function, which allows you to `populate` the saved document, this type of upserting behavior (and therefore enforcing adherence to the schema) is quite useful.

These changes rely on the sugary `$set` behavior of the update functions, as the document that is passed cannot, for obvious reasons, contain any operations.