I am aware that I can set the readPreference for each query using <collection>.withReadPreference(primaryPreferred()).find(...)
. However, I would prefer to set a global default readPreference to use "nearest" if possible, and then be able to override this for individual queries if necessary. Is there a possible/preferred way to do this using Jongo?
Edit: Since Jongo is initialized using MongoClient().getDB()
, would it therefor be suitable to initialize my MongoClient with options specifying the ReadPreference? I guess what I'm asking is - if I do it this way, will these settings carry over and be applied inside of Jongo, or is there a different way to handle it in Jongo directly?
Thanks ahead of time.