从stream()移动到cursor()时,lean()不再起作用

在这里添加的DeprecationWarning,似乎是说cursor()stream()一个插入replace,但是有一些function似乎已经被抛弃了。

例如,这个被弃用的代码将会有“瘦”的文件,而不是 mongoose.Document实例。文件:

 Cat .find({ }).lean() .stream() .on('data', function (data) { var value = data instanceof mongoose.Document; console.log('lean().stream() data instanceof mongoose.Document', value); }) .on('end', function () { }); 

并且这个代码将会有mongoose文档,即使在使用lean()时候:

 Cat .find({ }).lean() .cursor() .on('data', function (data) { var value = data instanceof mongoose.Document; console.log('lean().cursor() data instanceof mongoose.Document', value); }) .on('end', function () {}); 

这是因为它们的源代码在这个改变时看起来是相同的,

stream() : https : //github.com/Automattic/mongoose/blob/94557653dba2cd9046f1b2ffab427cef4632a7c3/lib/query.js#L2769

cursor() : https : //github.com/Automattic/mongoose/blob/94557653dba2cd9046f1b2ffab427cef4632a7c3/lib/query.js#L2816

是否有一个正确的方法来实现这与cursor()或我发现一个错误? 提前致谢 ;)

我经过研究发现(感谢JohnnyHK的评论),看起来好像没有在cursor() ,所以我提出了一个pull request来解决这个问题https://github.com/Automattic/mongoose/pull/ 4255