title: How to prefer reads on secondaries in MongoDb
body: <p>When using mongodb in a replica set configuration (1 arbiter, 1 primary, 2 slaves); how do I set a preference that read be performed against the secondaries and leave the primary only for writes? I'm using MongoDb 2.0.4 with Morphia. I see that there is a slaveOk() method, but I'm not sure how that works.</p>
  
  <p>Morphia <a href="http://code.google.com/p/morphia/" rel="noreferrer">http://code.google.com/p/morphia/</a></p>
  
  <p><b>Details</b>
  My Mongo is set with the following options:</p>
  
  <pre>
  mongo.slaveOk();
  mongo.setWriteConcern(WriteConcern.SAFE);
  </pre>
  
  <p>I am attempting to use the following (this may be answer -btw):</p>
  
  <pre>
  Datastore ds = getDatastore();
  Query&lt;MyEntity&gt; query = ds.find(MyEntity.class).field("entityId").equal(entityId);
  query.queryNonPrimary(); // appears equivalent to ReadPrefererence.secondary()
  MyEntity entity = query.get();
  </pre>