Model.hydrate()

Parameters
  • obj «Object»
  • [projection] «Object|String|Array<String>» optional projection containing which fields should be selected for this document
Returns:
  • «Document» document instance

Shortcut for creating a new Document from existing raw data, pre-saved in the DB. The document returned has no paths marked as modified initially.

Example:

  1. // hydrate previous data into a Mongoose document
  2. const mongooseCandy = Candy.hydrate({ _id: '54108337212ffb6d459f854c', type: 'jelly bean' });