Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1511

Cursor.prototype.count() is not respecting parent ReadPreference

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.0
    • Component/s: native
    • Labels:

      Description

      The following code will execute against the primary instead of the secondary:

      const url = 'mongodb://user:password@localhost:27018,localhost:27017,localhost:27019/test?replicaSet=replset';
       
      MongoClient.connect(url, { readPreference: ReadPreference.SECONDARY }, (err, client) => {
        const cursor = db.collection('test').find({});
        cursor.count().then(count => console.log("count: " + count));
      });
      

      It appears that the cursor does not respect the read preference of its parents.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: