从 stream() 移动到 cursor() 时,lean() 不再有效

lean() no longer works when moving from stream() to cursor()

截至添加的 DeprecationWarning here,似乎说 cursor()stream() 的直接替代品,但是,有些功能似乎已经留下来了。

例如,这个弃用的代码将有 "lean" 个文档 不是 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 () {});

super 很奇怪,因为他们的源代码在这个变化时看起来是一样的:

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