You can use collect[Stream]
instead of enumerate
on the Cursor instance to do that:
val collection: BSONCollection = db("ping")
val cursor: Cursor[Ping] = collection.find(BSONDocument()).cursor[Ping]
val stream: Stream[Ping] = cursor.toList.toStream
EDIT: Used cursor.toList.toStream
. This will gather all the documents matched by the query, then produce a stream.