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

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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.0
    • Affects Version/s: None
    • Component/s: Native
    • Labels:
      None

      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.

            Assignee:
            rebecca.weinberger Rebecca Weinberger
            Reporter:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: