libraryDependencies += "com.bcf" %% "reactivemongo4s-ce2" % "0.2.0"libraryDependencies += "com.bcf" %% "reactivemongo4s-ce3" % "0.2.0"libraryDependencies += "com.bcf" %% "reactivemongo4s-dsl" % "0.2.0"import com.bcf.reactivemongo4s.implicits._
import com.bcf.reactivemongo4s.dsl.BsonDsl._
val col: BSONCollection = ???
override def run(args: List[String]): IO[ExitCode] =
for {
res <- col.find("b" $exists true)
.cursor[SomeModel]()
.toStream[IO](100)
_ <- res.evalMap(model => IO.println(s"Got $model"))
.compile
.drain
count <- col.countF[IO]
_ <- IO.println("Count: " + count)
countAggregated <- col.aggregateWith[SomeModel]() { framework =>
import framework.{Count, Match}
List(
Match("b" $gte 1000),
Count("total")
)
}.headF[IO]
_ <- IO.println("countAggregated: " + countAggregated)
} yield ()import com.bcf.reactivemongo4s.dsl.BsonDsl._
val col: BSONCollection = ???
col.find($and("b" $exists true, "a" $nin Set(1,2), "c" $gte 20 $lt 100))$ docker network create mongo4cats
$ docker run --name mongo4cats --network mongo4cats -p 27017 -d mongo:latestCreate two collections for testing:
test1of size 1000test2of size 20
$ docker run -it --network mongo4cats --rm mongo mongo --host mongo4cats test
> use test
> let i = 0
> while (i < 1000) { db.test1.insertOne({"b": i}); i++ }
> let j = 0
> while (j < 20) { db.test2.insertOne({"b": j}); j++ }
> exit