mongo-scala-driver

Scala script wait for mongo to complete task

ぐ巨炮叔叔 提交于 2021-02-08 04:58:07
问题 I'm writing a simple scala-based script which supposed to insert some data into Mongo collection. The problem is, that script exits before mongo finishes it's task. What is the idiomatic/best approach to deal with the problem, considering following script: #!/usr/bin/env scalas /*** scalaVersion := "2.12.2" libraryDependencies ++= { Seq( "org.mongodb.scala" %% "mongo-scala-driver" % "2.1.0" ) } */ import org.mongodb.scala._ val mongoClient: MongoClient = MongoClient("mongodb://localhost") val

How to create Decimal128 field with inc operator in java/scala

笑着哭i 提交于 2020-01-04 05:40:08
问题 I have following document structure: { "moneys": { "someKey": NumberDecimal(99) ... "someOtherRandomKey": NumberDecimal(99) } { What I want : When nonexistent field increments, create that field with NumberDecimal value. I tried it with scala driver but cant do that: //not compiles collection.findOneAndUpdate(filters,Updates.inc("someOtherKey", new Decimal128(50))) because Updates.inc(k,v) requires Number ; Decimal128 is not Number I think problem not in driver, but with my logic. How can I