Questions tagged [reactivemongo]

Asynchronous & Non-Blocking Scala Driver for MongoDB

508 questions
3
votes
2 answers

How to get a result from Enumerator/Iteratee?

I am using play2 and reactivemongo to fetch a result from mongodb. Each item of the result needs to be transformed to add some metadata. Afterwards I need to apply some sorting to it. To deal with the transformation step I use enumerate(): def…
DanielKhan
  • 1,190
  • 1
  • 9
  • 18
3
votes
1 answer

Scala - Unit found required: play.api.mvc.SimpleResult

I'm really confused here, i'm probably missing something obvious so it would be great if someone could point me into the right direction. I've got this following function that returns a future of a SimpleResult type but it has a unit instead . …
unleashed
  • 915
  • 2
  • 16
  • 35
3
votes
2 answers

Play & ReactiveMongo: How to deserialize Json from request in controller

Here below is again the case class I presented in my previous post... but with the fix suggested by cmbaxter: case class User( id: Option[BSONObjectID], name: String, addresses: Option[List[BSONObjectID]] ) object User { implicit object…
j3d
  • 9,492
  • 22
  • 88
  • 172
3
votes
1 answer

Translate mongodb aggregate function to ReactiveMongo and scala

I'm trying to implement an aggregate method in ReactiveMongo but I'm a bit stuck. I have the following dataset: { "_id" : ObjectId("522891aa40ef0b5d11cb9232"), "created" : 1378390442167, "origin" : 2, "originIpAddress" : "", …
jakob
  • 5,979
  • 7
  • 64
  • 103
3
votes
1 answer

Approach to read data from mongodb using reactive mongo irrespective of the structure

I'm using reactivemongo. While reading document from mongodb I have written code specific to the structure. Structure { "name" : "test", "age" : 3 } For reading this I am using code like : val cursor =…
Nitin
  • 57
  • 7
3
votes
1 answer

Play2 & ReactiveMongo testing issue: db connection right after test fails

I am implementing a file storage service, which is taking a file and saving it into gridFS with special metadata. Of course, I want to be sure everything's working in integration -- files are really stored in database and then retrieved from it. I…
3
votes
2 answers

Using specs2 play! fake application with Reactivemongo causes timeouts

We are currently working on an issue where we use specs2 in scala togeather with mongodb/reactivemongo + Play!. When we run the tests that write to mongodb the first operation runs fine the all subsequent tests/writes fail due to a timeout when to…
Max Charas
  • 4,980
  • 3
  • 20
  • 40
3
votes
1 answer

Compiler error on nested futures response with Play and ReactiveMongo

I have a mongo entry where one field is a list. If entry doesn't exist, I want to add new one. If it exists, I want to append a new element to the list. At the end I want to return an Ok to the client, but only after the operation was completed…
User
  • 31,811
  • 40
  • 131
  • 232
2
votes
1 answer

Could not find implicit value for parameter write eror, yet I defined the handler using the macro

I have the following: Account.scala package modules.accounts import java.time.Instant import reactivemongo.api.bson._ case class Account(id: String, name: String) object Account { type ID = String implicit val accountHandler:…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
2
votes
0 answers

BSON to Play JSON support for Long values

I've started using the play-json/play-json-compat libraries with reactivemongo 0.20.11. So I can use JSON Play reads/writes while importing the 'reactivemongo.play.json._' package and then easily fetch data from a JSONCollection instead of a…
2
votes
1 answer

Should I create recursive method for retry in mongodb transaction to avoid document level lock error?

I am using mongodb transaction. Sometimes it may happen that for concurrent transaction in same document data update the second transaction will create transient transaction error which will abort the second concurrent update. In this case retry…
John
  • 2,633
  • 4
  • 19
  • 34
2
votes
1 answer

How to load the ReactiveMongo for both linux and osx when defining the dependencies?

I am trying to setup my RractiveMongo dependancy for both linux and osx platforms. I tried this: val mongoShadedNativeLinux = "org.reactivemongo" % "reactivemongo-shaded-native" % s"$reactivemongoVersion-linux-x86-64" classifier…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
2
votes
1 answer

How to: $merge and On-Demand-Materialized views

In the Mongo docs on materialized views i saw this example: updateMonthlySales = function(startDate) { db.bakesales.aggregate( [ { $match: { date: { $gte: startDate } } }, { $group: { _id: { $dateToString: { format: "%Y-%m", date:…
2
votes
0 answers

ReactiveMongo with Cluster DocumentDB throw internal server error after warning timeout connection

We are using Playframework 2.7.x, Scala 2.13.x, ReactiveMongo 0.19.2 and a Cluster DocumentDB, when We put in the connection string pointing to cluster mongodb://user:pwd@clusterhost:27017/db-name?replicaSet=rs0 We had this error Dec 5 22:50:23…
pablopaho
  • 43
  • 1
  • 6
2
votes
1 answer

How to write documents to MongoDB using ReactiveMongo transactions?

I am trying to run this simple code, which insert a document to "reports" collection under transaction. This is the code: def runWithTransaction(): Future[Unit] = { for { dbWithSession <- db.db.startSession() dbWithTx <-…
Ameen
  • 137
  • 3