Asynchronous & Non-Blocking Scala Driver for MongoDB
Questions tagged [reactivemongo]
508 questions
2
votes
1 answer
uploading a file in a non-blocking manner without using gridFSBodyParser(gridFS)
The plugin play-reactivemongo offers an easy way to upload a file:
def upload = Action(gridFSBodyParser(gridFS)) { request =>
val futureFile: Future[ReadFile[BSONValue]] = request.body.files.head.ref
futureFile.map { file =>
// do something
…

Franck Valentin
- 1,115
- 8
- 14
2
votes
1 answer
ReactiveMongo: find query with cursor[BSONObjectID]
My query using ReactiveMongo:
collection
.find(
Json.obj("relateds" -> Json.obj("$elemMatch" -> activityRelated)),
Json.obj("subscriberId" -> 1, "_id" -> 0)
)
.cursor[BSONObjectID]
.collect[Seq]()
This is meant to return only one…

Ayoub
- 361
- 4
- 15
2
votes
2 answers
ReactiveMongo & JSON4S
I'm using JSON4S to parse some JSON strings I'm getting from external APIs.
Is there anyway to get JSON entities like there is with the play reactivemongo JSONCollection or the spray-json to reactive mongo converter in sprest?
Its easy to use…

NightWolf
- 7,694
- 9
- 74
- 121
2
votes
1 answer
Resize an uploaded image in PlayFramework using ReactiveMongo and GridFS
I am using Play Framework and ReactiveMongo DB in order to store an uploaded file in GridFS. Here is the code:
def saveAttachment(id: String) = Action.async(gridFSBodyParser(gridFS)) { request =>
// here is the future file!
val futureFile =…

bashan
- 3,572
- 6
- 41
- 58
2
votes
1 answer
Handling optional values in BSONDocument
I am having difficulty with the way optional values are handled by BSONDocuments in an application. I started with the "eventual" template from Typesafe activator (play/reactivemongo/angular). I created a case class representing an object to go into…

Willard
- 337
- 2
- 8
2
votes
1 answer
Play 2.2.x, Action Composition with Authentication and Request extension
I am trying to create an ActionBuilder which checks if the user is loggedin and if so, add the user object to the request(AuthenticatedRequest). With MySQL this would be easy because resolving the user would not get a Future object. But in this…

leMale
- 179
- 1
- 11
2
votes
1 answer
ReactiveMongo: How to convert BSON returned by FindAndModify to JSON
Here below is the code for updating a document with Mongo's FindAndModify:
val selector = BSONDocument("id" -> "1234")
val modifier = BSONDocument("$set" -> BSONDocument("email" -> "new@domain.com")) …

j3d
- 9,492
- 22
- 88
- 172
2
votes
1 answer
ReactiveMongo Connection, keep connection object alive in the Play context or re-establish for each call to the database? (Play, Scala, ReactiveMongo)
I am just starting to use ReactiveMongo with Play 2 (scala).
Should I store a singleton object with the connection details and a return of the database (connection.get.db("mydb")) or keep the connection alive indefinitely.
I am used to JDBC…

Zuriar
- 11,096
- 20
- 57
- 92
2
votes
4 answers
ReactiveMongo: How to deal with database errors when inserting new documents
I've a MongoDB collection where I store User documents like this:
{
"_id" : ObjectId("52d14842ed0000ed0017cceb"),
"email": "joe@gmail.com",
"firstName": "Joe"
...
}
Users must be unique by email address, so I added an index for the…

j3d
- 9,492
- 22
- 88
- 172
2
votes
2 answers
Upsert many records using ReactiveMongo and Scala
I am writing a DAO Actor for MongoDB that uses ReactiveMongo. I want to implement some very simple CRUD operations, among which the ability to upsert many records in one shot. Since I have a reactive application (built on Akka), it's important for…

Giovanni Botta
- 9,626
- 5
- 51
- 94
2
votes
1 answer
Reactivemongo serializing a map into a BSONDocument
I defined BSONDocumentWriters to map domain objects (case classes) to BSON documents to be persisted in MongoDB using the ReactiveMongo driver. Defining the writers is quite straight-forward for case classes (although tedious and error prone: I wish…

Giovanni Botta
- 9,626
- 5
- 51
- 94
2
votes
2 answers
Case classes for formatting json - with and without the object id
I am writing a play2 app that gets data via rest/json and stores it in mongodb using reactivemongo.
I am using a model built from case classes and implicit val myFormat = Json.format[myCaseClass]
Currently I have a case class for objects coming from…

DanielKhan
- 1,190
- 1
- 9
- 18
2
votes
1 answer
Best way to store/get values referenced from a list in Mongo/RectiveMongo?
I have a quite common use case - a list of comments. Each comment has an author.
I'm storing the reference from a comment to the author using a reference, since an author can make multiple comments.
Now I'm working with ReactiveMongo and want to try…

User
- 31,811
- 40
- 131
- 232
2
votes
1 answer
How to override a gridfs file within the Play Framework using reactivemongo?
I have the following code to write a gridfs file:
request.body.files.toList.lastOption match {
case Some(picture) => {
val filename = picture.filename
val contentType = picture.contentType
picture.ref.moveTo(new File("/tmp/"…

G A
- 571
- 3
- 6
- 18
2
votes
1 answer
Play! Framework controller returns EMPTY RESPONSE after adding reactivemongo plugin
I am quite new to reactivemongo and Play framework. I was working on a Play application when time to add MongoDB connection came. I decided to go with reactiveMongo and made everything according to the tutorial…

Alex K
- 854
- 9
- 16