1

Is there a way when working with find operations to capture as values both emerging decoding exceptions and the data ?

When decoding all the retrieved BSONs some may have invalid properties and will not be decodable into domain object.

What i had in mind:

  val findAsyncResult: Future[List[Either[DecodingExceptions, Data]]] =
      database
        .getCollection[String](???)
        .find(???)
        .toFuture()
}

I noticed that when one value can't be decoded the whole operation is failed. I was hopping i can somehow accumulate errors and valid data.

gatear
  • 946
  • 2
  • 10

0 Answers0