Printing query results from Mongodb in Scala using mongo-scala-driver
<p>I'am trying to print results from a MongoDB query in Scala</p>

<pre><code>val mongoClient: MongoClient = MongoClient()
val database: MongoDatabase = mongoClient.getDatabase("tableScala")
val collection: MongoCollection[Document] = database.getCollection("tableScala")

collection.find().printResults()
</code></pre>

<p>The error thrown was : <code>Cannot resolve symbol printResults</code>. Answers to some other questions suggested to use <code>mongo-scala-driver</code> version <code>1.2</code>, as printResults() is not implemented for version <code>1.1</code> and below</p>

<p>SBT file:</p>

<pre><code>name := "scalaMongoDriver"

version := "1.0"

scalaVersion := "2.11.8"

libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "1.2.0-beta1"
</code></pre>

<p>Tried to print manually using :</p>

<pre><code>collection.find().subscribe(
      (user: Document) =&gt; println(user.toJson()),                         // onNext
      (error: Throwable) =&gt; println(s"Query failed: ${error.getMessage}"), // onError
      () =&gt; println("Done")                                               // onComplete
    ) 
</code></pre>

<p>resulted in the following info:</p>

<blockquote>
  <p>INFO: No server chosen by
  ReadPreferenceServerSelector{readPreference=primary} from cluster
  description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE,
  serverDescriptions=[ServerDescription{address=localhost:27017,
  type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing
  out</p>
</blockquote>

<p>Is there any way to view the retrieved results in console?</p>