package eu.xeppaka.scalalearn

import org.mongodb.scala.MongoClient
import org.mongodb.scala.bson.collection.immutable.Document

import scala.concurrent.Await
import scala.concurrent.duration._

object Main4 {
  def main(args: Array[String]): Unit = {
    val mongoClient = MongoClient("mongodb://localhost:27017/?maxPoolSize=2")
    val db = mongoClient.getDatabase("my-db1")

    for (i <- 1 to 100) {
      val col = db.getCollection(s"col$i")
      col.insertOne(Document("{field1:12}")).toFuture()
      //Await.result(f1, 1.second)
    }

    Thread.sleep(5000)

    //mongoClient.close()
  }
}
