MongoError: Unrecognized pipeline stage name: '$changeStream'

匿名 (未验证) 提交于 2019-12-03 09:18:39

问题:

We are getting this error:

   MongoError: Unrecognized pipeline stage name: '$changeStream'         at queryCallback (/Users/alexamil/WebstormProjects/nabisco/cdt-now/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:244:25)         at /Users/alexamil/WebstormProjects/nabisco/cdt-now/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:544:18         at _combinedTickCallback (internal/process/next_tick.js:131:7)         at process._tickDomainCallback (internal/process/next_tick.js:218:9) 

We have this file, which will update some caches on our server:

'use strict';  import caches = require('../../models/caches');  import {Phase, Acquisition, Category, FunctionalGroup, Role, User, Workstream} from "../../models";  Acquisition.watch().on('change', function (c) {   console.log('acq change:', c); });  Category.watch().on('change', function (c) {   console.log('category change:', c); });  FunctionalGroup.watch().on('change', function (c) {   console.log('functional team change:', c); });  Role.watch().on('change', function (c) {   console.log('role change:', c); });  User.watch().on('change', function (c) {   console.log('user change:', c); });  Workstream.watch().on('change', function (c) {   console.log('workstream change:', c); }); 

we are migrating from Mongo 2.6 to Mongo 3.4, so some of our data might be missing fields.

Does anyone know how to mitigate this error?

We are now using mongoose version 5.0.16.

回答1:

Change streams are new in MongoDB 3.6. If you use MyModel.watch() in mongoose when connected to an older version of the MongoDB server, you'll get this error.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!