代码之家  ›  专栏  ›  技术社区  ›  Orelsanpls

类型错误:无法读取result.toArray中未定义\n的属性“n”

  •  1
  • Orelsanpls  · 技术社区  · 8 年前

    我正在从 mongodb 3.6升级到 mongodb 4.0 and have problem with aggregates (it seeps)

    我有个错误:

    类型错误:无法在处读取未定义的属性“n” 结果.ToArray (/eliot本地git/node_modules/mongodb/lib/operations/collection_ops.js:237:46)\n 结果 (/eliot local git/node_modules/mongodb/lib/utils.js:414:17)位于 执行回拨 (/eliot local git/node_modules/mongodb/lib/utils.js:406:9)位于 手背式 (/eliot local git/node_modules/mongodb/lib/utils.js:128:55)位于 光标.close (/eliot local git/node_modules/mongodb/lib/operations/cursor_ops.js:218:62)在handleCallback上 (/eliot local git/node_modules/mongodb/lib/utils.js:128:55)位于 完全失去 (/eliot local git/node_modules/mongodb/lib/cursor.js:887:14)位于 _ 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)位于 aggregationcursor.cursor.close (/eliot local git/node_modules/mongodb/lib/cursor.js:898:19)位于 光标。_下一步 (/eliot local git/node_modules/mongodb/lib/operations/cursor_ops.js:218:23)在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 自言自语。 (/eliot local git/node_modules/mongodb/node_modules/mongodb core/lib/cursor.js:568:46)\n 在aggregationcursor.cursor.\endsession (/eliot本地git/node_modules/mongodb/node_modules/mongodb core/lib/cursor.js:193:5)


    我的总呼叫如下:

    collectionschema.aggregate(query.exec();
    

    使用:

    MongoDB 4.0.0版


    我也试过用光标,但没用:

    聚合(查询) .光标({ 批量:10 }) .exec();

    @alex blexhereis where I saw the compatibility tomongodb native driver 3.1.

    .

    类型错误:无法在处读取未定义的属性“n” 结果.ToArray (/eliot本地git/node_modules/mongodb/lib/operations/collection_ops.js:237:46)\n 结果 (/eliot local git/node_modules/mongodb/lib/utils.js:414:17)位于 执行回拨 (/eliot local git/node_modules/mongodb/lib/utils.js:406:9)位于 手背式 (/eliot local git/node_modules/mongodb/lib/utils.js:128:55)位于 光标.close (/eliot local git/node_modules/mongodb/lib/operations/cursor_ops.js:218:62)在handleCallback上 (/eliot local git/node_modules/mongodb/lib/utils.js:128:55)位于 完全失去 (/eliot local git/node_modules/mongodb/lib/cursor.js:887:14)位于 _ 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)位于 aggregationcursor.cursor.close (/eliot local git/node_modules/mongodb/lib/cursor.js:898:19)位于 光标。_下一步 (/eliot local git/node_modules/mongodb/lib/operations/cursor_ops.js:218:23)在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 自言自语。 (/eliot local git/node_modules/mongodb/node_modules/mongodb core/lib/cursor.js:568:46)\n 在aggregationcursor.cursor.\endsession (/eliot本地git/node_modules/mongodb/node_modules/mongodb core/lib/cursor.js:193:5)


    我的总呼叫如下:

    collectionSchema.aggregate(query).exec();
    

    使用:

    MongoDB 4.0.0版

    enter image description here


    我也试过使用光标,但没用:

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

    @亚历克斯·布利克斯here在那里我看到了mongodb-native-driver 3.1

    推荐文章