LearnBoost/mongoose — pull request #2292 by cstigler (2014-09-10 17:21:29+00:00)
Title: Add Model.hydrate() and test case

As mentioned in issue #2290 , there is currently no good way to produce a Mongoose object from data pre-saved to the DB. ```new MyObj()``` works but sets ```isNew``` to true and all paths to modified.

This PR introduces a simple ```Model.hydrate(obj)``` method that turns raw object data (such as that created with ```doc.toObject()```) into a Mongoose doc with isNew=false and no paths marked modified. I included a simple test also (I don't think it needs too much since it's pretty simple).

Use-case: we cache users outside of the normal Mongo collection. We need to be able to take users from our cache and use them as if they originated from Mongo in that state.