MongoError:已请求多数阅读问题,但存储引擎不支持该问题

时间:2018-12-15 19:44:53

标签: javascript node.js mongodb mlab

我正在使用mlab免费套餐,并且试图在我的应用程序中使用更改流。这是我的代码:

const config = require('../globals/config');
const MongoClient = require('mongodb').MongoClient;
MongoClient.connect(config.db, {useNewUrlParser: true}, function (err, client) {
    const db = client.db('web-project-studio-db');
    // Connect using MongoClient
    var filter = [{$match: {'_id': user._id}}];

    db.collection('accounts').watch(filter).on('change', data => {
        console.log(data);
    });
});

这说:

  

MongoError:已请求多数读取关注,但存储引擎不支持该关注。

我应该在mlab设置中启用某些功能,还是只是搞砸了?

1 个答案:

答案 0 :(得分:4)

要使用watch,您需要使用不属于mLab free plan的副本集。