LearnBoost/mongoose — pull request #2049 by lbeschastny (2014-04-29 10:40:55+00:00)
Title: Mongoose `.find()` method corrupts options object

I found a very interesting bug in latest mongoose.

Consider the following code:

```js
var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/test');

var Foo = mongoose.model('Foo', new mongoose.Schema({
data: String
}));

var opts = {};

Foo.find({}, 'data', opts).lean().exec().then(function() {
console.log('opts =', opts);
process.exit();
});
```

You would expect `opts` object to remain intact after `Foo.find`, but instead of picking all the values from it, Mongoose extends it internally, changing original object:

opts = { lean: true }

Of course, JS programmer should always expect such thing to happen, but I think that it's a bug anyway.