Make MongoClient prefer secondaries

This commit is contained in:
Erki Aas 2022-10-11 02:23:54 +03:00
parent 7797eb9210
commit cfcd17d45e

View File

@ -15,8 +15,10 @@ const pipeline = [];
const PORT = process.env.PORT || 3002;
// Create Mongo client
const mongoClient = new MongoClient(mongoUri);
const mongoOptions = {
readPreference: 'secondaryPreferred'
}
const mongoClient = new MongoClient(mongoUri, mongoOptions);
/*============== CODE ==============*/
async function run() {