find ignores the collection's read preference and read concern
In both official drivers, find always calls withReadPreference(...) and withReadConcern(...) on the inner
collection. When the call doesn't set those options, readReadPreference() returns primary() and readReadConcern()
returns ReadConcern.DEFAULT, which replace whatever the collection was configured with:
val users = database.getCollection<User>("users")
.withReadPreference(ReadPreference.secondaryPreferred())
.withReadConcern(ReadConcern.MAJORITY)
.asKtMongo()
users.find { } // sent with $readPreference: primaryPreferred*, and no readConcern* primaryPreferred is how the driver sends primary on a direct connection.
count and aggregate don't override them, and the write concern is only applied when its option is set, so find
is the odd one out.
!335 (merged) applies the read preference and read concern the same way as the write concern: only when the option is set.
Edited by Sejal Patel