1

我正在从mongodb 3.6to升级mongodb 4.0并遇到聚合问题(似乎)

我有这个错误:

类型错误:无法在 result.toArray (/eliot-local-git/node_modules/mongodb/lib/operations/collection_ops.js:237:46) 处读取未定义的属性 'n'\n 结果 (/eliot-local- git/node_modules/mongodb/lib/utils.js:414:17)\n 在 executeCallback (/eliot-local-git/node_modules/mongodb/lib/utils.js:406:9)\n 在 handleCallback (/eliot- local-git/node_modules/mongodb/lib/utils.js:128:55)\n 在 cursor.close (/eliot-local-git/node_modules/mongodb/lib/operations/cursor_ops.js:218:62)\n在 handleCallback (/eliot-local-git/node_modules/mongodb/lib/utils.js:128:55)\n 在 completeClose (/eliot-local-git/node_modules/mongodb/lib/cursor.js:887:14) \n 在 _endSession (/eliot-local-git/node_modules/mongodb/lib/cursor.js:898:37)\n 在 AggregationCursor.Cursor。_endSession (/eliot-local-git/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:193:5)\n 在 AggregationCursor.Cursor._endSession (/eliot-local-git/node_modules/mongodb/lib /cursor.js:226:59)\n 在 AggregationCursor.Cursor.close (/eliot-local-git/node_modules/mongodb/lib/cursor.js:898:19)\n 在 cursor._next (/eliot-local -git/node_modules/mongodb/lib/operations/cursor_ops.js:218:23)\n 在handleCallback (/eliot-local-git/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:202:5 )\n 在 _setCursorNotifiedImpl (/eliot-local-git/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:560:38)\n 在 self._endSession (/eliot-local-git/node_modules/mongodb /node_modules/mongodb-core/lib/cursor.js:568:46)\n 在 AggregationCursor.Cursor。_endSession (/eliot-local-git/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:193:5)


我的总调用看起来像:

collectionSchema.aggregate(query).exec();

使用 :

mongodb v4.0.0

在此处输入图像描述


我也尝试过使用光标,但它不起作用:

collectionSchema.aggregate(query)
        .cursor({
          batchSize: 10
        })
        .exec();

@Alex Blex在这里我看到了兼容性mongodb-native-driver 3.1

在此处输入图像描述

4

1 回答 1

1

有一个错误https://jira.mongodb.org/browse/NODE-1543,14 小时前在 v3.1.1 中修复:https ://github.com/mongodb/node-mongodb-native/commit/09c7d8e4ce302f1c8f6339dd19ee4b86e40b30a8

于 2018-07-04T09:12:26.797 回答