2

I'm using official mongo-scala-driver 2.0.0. And try update field with BigDecimal value:

myCollection.findOneAndUpdate(
  equal("_id", "someId"),
  set("money", BigDecimal(100.0))
).headResult()

And it give's me:

org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class scala.math.BigDecimal

But insertion accepts BigDecimal:

  myCollection
      .insertOne(
        Document("_id" -> "someId", "money" -> BigDecimal(100.0))
      ).headResult()

What is correct way to update BigDecimal field? Is that correct, that insertion supports codec, but update - not

zella
  • 4,645
  • 6
  • 35
  • 60
  • 2
    had the same problem. This one solution helped me: https://stackoverflow.com/questions/45053457/how-to-create-decimal128-field-with-inc-operator-in-java-scala – Capacytron Jan 27 '18 at 13:47

0 Answers0