I have a case class with a field that is Double:
case class MyModel(amount: Option[Double])
I work with mongodb4 and use reactivemongo 0.19.0 with play framework 2.7.2 with Scala 2.12.8
from some reason, randomly, when I insert MyModel elements to the db amount field saved as int64 instead of Double, which is very weird cause most of the time not, just randomly.
its not a decimal point thing cause I saw other documents that this field don't have decimal point and it still saved as Double correctly.
what are your thoughts?
this is the insertion function:
def insertOneWithoutEvent(doc: Doc): Future[Doc] = {
doc.createdAt = Some(InstantNow)
doc.updatedAt = doc.createdAt
(for {
insertedDoc <- collection.insert.one(doc)
.map({
case DefaultWriteResult(true, 1, _, _, _, _) => doc
case dwr => throw new RuntimeException(s"$LogName was not inserted, something went wrong: $dwr")
})
} yield insertedDoc)
.recover({
case WriteResult.Code(DuplicateCode) => throw DuplicateKeyException(doc.uniqueIndexToString)
})
}