LearnBoost/mongoose — pull request #2447 by chmanie (2014-11-08 21:10:58+00:00)
Title: toObject() with custom transform function and subdocuments

There is an issue regarding a very special edge-case.

The following perquisites have to be met:

1) Using toObject() on the root document with a custom transform function:
```
doc.toObject({
transform: function(doc, red) {} // can be any function
});
```
2) The root document does not have a transform function set in the schema. ```doc.schema.toObject.transform === undefined```

3) A subdocument inside the root document has a transform function set in the schema.

In this case the subdocuments transform function is overwriting the transform function specified when called doc.toObject(). As I do not think this is intended behaviour I created this PR. It adds a test for this case and comes with a possible solution.