MongoError: Majority read concern requested, but it is not supported by the storage engine
MongoError: Majority read concern requested, but it is not supported by the storage engine
我正在使用 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 的副本集。
我正在使用 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 的副本集。