{"action":"created","issue":{"url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2637","labels_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2637/labels{/name}","comments_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2637/comments","events_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2637/events","html_url":"https://github.com/LearnBoost/mongoose/issues/2637","id":56293855,"number":2637,"title":"feature request: Cast plain object to mongoose document","user":{"login":"DesignByOnyx","id":514040,"avatar_url":"https://avatars.githubusercontent.com/u/514040?v=3","gravatar_id":"","url":"https://api.github.com/users/DesignByOnyx","html_url":"https://github.com/DesignByOnyx","followers_url":"https://api.github.com/users/DesignByOnyx/followers","following_url":"https://api.github.com/users/DesignByOnyx/following{/other_user}","gists_url":"https://api.github.com/users/DesignByOnyx/gists{/gist_id}","starred_url":"https://api.github.com/users/DesignByOnyx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DesignByOnyx/subscriptions","organizations_url":"https://api.github.com/users/DesignByOnyx/orgs","repos_url":"https://api.github.com/users/DesignByOnyx/repos","events_url":"https://api.github.com/users/DesignByOnyx/events{/privacy}","received_events_url":"https://api.github.com/users/DesignByOnyx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/LearnBoost/mongoose/labels/help","name":"help","color":"FFFFFF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-02-02T21:12:39Z","updated_at":"2015-02-05T16:08:36Z","closed_at":null,"body":"RE: http://stackoverflow.com/questions/24190478/cast-plain-object-to-mongoose-document\r\n\r\nWhen mongoose loads data from the database, it converts (casts) that data into instances of mongoose Document.  It would be nice if this functionality was exposed to the outside world, or if mongoose would provide some sort of best practices recommendation.  I am posting this request because other users on SO voted for it."},"comment":{"url":"https://api.github.com/repos/LearnBoost/mongoose/issues/comments/73072555","html_url":"https://github.com/LearnBoost/mongoose/issues/2637#issuecomment-73072555","issue_url":"https://api.github.com/repos/LearnBoost/mongoose/issues/2637","id":73072555,"user":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"created_at":"2015-02-05T16:08:36Z","updated_at":"2015-02-05T16:08:36Z","body":"Ahhhh I see your point. So how hydrate works is that all fields are in \"init\" state when the model is hydrated, which means validation runs as shown in the commit I just pushed, but no fields are marked as dirty to be saved to the db initially, unless you make changes. IMO this makes sense with how hydrate() is supposed to work: its assumed the data is saved in the db and you got it using the node driver or some other tool.\r\n\r\nI think a better tool for your use case would be to simply look up the document from the db by its id, no? "}}