我正在使用 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: Majority read concern requested, but it is not supported by the storage engine.
我应该在 mlab 设置中启用某些功能,还是我只是搞砸了一些东西?
最佳答案
要使用watch
,您需要使用不属于mLab free plan的副本集.
关于javascript - MongoError : Majority read concern requested, 但存储引擎不支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53796666/