From 8a87add561d187d5dd78d9b5520821539eafc691 Mon Sep 17 00:00:00 2001
From: Andreas Kohn <andreas.kohn@gmail.com>
Date: Mon, 25 Sep 2017 16:28:45 +0200
Subject: [PATCH] Use the read preference of the connection when listing
 collections

---
 lib/db.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/db.js b/lib/db.js
index e604a30f..55a26771 100644
--- a/lib/db.js
+++ b/lib/db.js
@@ -667,9 +667,16 @@ Db.prototype.listCollections = function(filter, options) {
   // Set the promise library
   options.promiseLibrary = this.s.promiseLibrary;
 
-  // Ensure valid readPreference
+  // If we have a readPreference set
+  if(options.readPreference == null && this.s.readPreference) {
+    options.readPreference = this.s.readPreference;
+  }
+
+  // Convert the readPreference if its not a write
   if(options.readPreference) {
     options.readPreference = convertReadPreference(options.readPreference);
+  } else {
+    options.readPreference = CoreReadPreference.primary;
   }
 
   // We have a list collections command
-- 
2.13.5

