Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(op-msg): only include $readPreference if not primary
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Feb 20, 2019
1 parent dccc2ba commit 0d10317
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/connection/msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

const opcodes = require('../wireprotocol/shared').opcodes;
const databaseNamespace = require('../wireprotocol/shared').databaseNamespace;
const ReadPreference = require('../topologies/read_preference');

// Incrementing request id
let _requestId = 0;
Expand All @@ -49,7 +50,7 @@ class Msg {
this.command = command;
this.command.$db = databaseNamespace(ns);

if (options.readPreference) {
if (options.readPreference && options.readPreference.mode !== ReadPreference.PRIMARY) {
this.command.$readPreference = options.readPreference.toJSON();
}

Expand Down

0 comments on commit 0d10317

Please sign in to comment.