LearnBoost/mongoose — pull request #765 by richtera (2012-03-09 03:17:52+00:00)
Title: Added support for toJSONOptions and toObjectOptions

By default toJSON and toObject will not get any parameters. So if you stringily a whole bunch of records there is really no good way to pass options down to each sub object. By default I wanted to be able to setup a schema to include virtuals as part of their json representation since I am sending the json packet to the client. I found two problems with this.
1. By default toJSON was being called with 0 and not an object. This type of param was not really being considered by toJSON and would also drop the options.json = true since 0.json does nothing.
2. When passing no parameter to toJSON or toObject there was really no way to default the parameters.
Now I added two new options into the Schema constructor called toObjectOptions and toJSONOptions which default the options for those two functions if called with no params.