Questions tagged [mongo-scala-driver]

57 questions
5
votes
1 answer

Scala mongo driver custom codec for case classes

The scala-mongo-driver has a decent documentation for working with case classes. http://mongodb.github.io/mongo-scala-driver/2.3/getting-started/quick-tour-case-classes/. In current situation my case class fields are Option[T] values. So the values…
Ambareesh B
  • 499
  • 1
  • 5
  • 14
5
votes
0 answers

deserializing mongo document's DateField into java.util.Date

I'm using mongo-scala combination in one of my new projects and it requires deserializing a mongo document with date field mongo document example { "_id" : ObjectId("56603577616e082f559da3d9"), "type" : "rule", "startTime" :…
Rohit
  • 1,878
  • 19
  • 26
4
votes
0 answers

Mongo scala driver 2.0 with non default akka execution context

I have started using mongo scala driver in our scala akka-http project and it has been great help especially the case class support in v2.0.0 is very nifty. I'm trying to wrap my head around how to use the mongo scala driver with non-default…
makeyourrules
  • 63
  • 1
  • 6
4
votes
0 answers

IllegalArgumentException: Invalid BSON field name uuid

So I've tried seemingly countless things to get this to work. When I call queueWrite, the println statements give me this: { "uuid" : "49f2-0b64-4bf3-49f2a35b-bbe8-4954f742d88b" } and this: { "uuid" : "49f2-0b64-4bf3-49f2a35b-bbe8-4954f742d88b",…
annon
  • 107
  • 1
  • 11
4
votes
2 answers

Not persisting Scala None's instead of persisting as null value

I noticed that the scala driver (version 1.2.1) writes Option values of None as null to the corresponding field. I would prefer omitting the fieid completely in this case. Is this possible? Example case class Test(foo:…
neurolabs
  • 542
  • 3
  • 8
3
votes
1 answer

match element in array of mongodb

I have collection as follows . { "name" : "pqr" , "loc" : [ {"area" : "c" , "country" : "d"}, {"area" : "w" , "country" : "r"} ] } I want to make which match such that only match the first element of array loc that means if…
Swapnil Sonawane
  • 1,445
  • 3
  • 22
  • 37
3
votes
1 answer

Mongo-Scala-Driver: CodecConfigurationException: can't find a codec for class immutable.Document

Error message: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.mongodb.scala.bson.collection.immutable.Document Code: def queueWrite(collection: String, filter: Map[String, () => String], data:…
annon
  • 107
  • 1
  • 11
2
votes
0 answers

How to restrict mongo-spark-connector making too many connections to mongo cluster?

I've built a simple data exporter job in spark using mongo-spark-connector. This job reads collections from mongo and writes it into S3. However, for collections of huge size (2B documents), it opens up too many connections irrespective of the…
pushpavanthar
  • 819
  • 6
  • 20
2
votes
0 answers

Getting Boxed error in Mongo Scala Driver while applying the aggregation

I am trying to apply aggregation with lookup in MongoDB with Mongo Scala Driver and while I try to fetch result, I get the Boxed Error. val query: AggregateObservable[Document] = collection.aggregate(Seq( lookup("training", "trainingId", "_id",…
2
votes
0 answers

How to parse Document to Json - Mongo scala driver

I'm using play framework and mongo scala driver to set a database up, I need to parse the result of a query to Json to send it to the front-end: def getAllProcess(userId: String) = { getCollection(COMPANY_FORM).find(equal("userId",…
Azoulay Jason
  • 2,787
  • 5
  • 21
  • 46
2
votes
1 answer

Scala script wait for mongo to complete task

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…
RB_
  • 1,195
  • 15
  • 35
2
votes
1 answer

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

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…
zella
  • 4,645
  • 6
  • 35
  • 60
2
votes
3 answers

Scala + MongoDB: optional fields and immutables

I have this domain object: case class Person ( name : String, age: Option[Int], email : String ) extends MongoObject with the age optional field. So I defined my factory: object Person extends MongoObjectShape[Person] { lazy val name =…
onof
  • 17,167
  • 7
  • 49
  • 85
2
votes
2 answers

Mongo Scala Driver 2.1 - case class error

This is my first time working with the Mongo Scala driver (version 2.1) and I am noticing odd behavior in the handling of some of my case classes -- some of them are not being recognized as such in the classToCaseClassMap with the result that…
KevinD
  • 31
  • 3
2
votes
1 answer

Scala MongoDB Driver - How to perform blocking on Observable and Inserting

So I have 2 collection, lets say its new collection and other collection and I wanted to insert data from this other collection to a whole new collection in which the other collection contains data that could be processed to a new form of data in…
albertjtan
  • 171
  • 2
  • 14
1
2 3 4