Play-ReactiveMongo is a plugin for Play 2.x, enabling support for ReactiveMongo – reactive, asynchronous and non-blocking Scala driver for MongoDB.
Questions tagged [play-reactivemongo]
148 questions
0
votes
1 answer
Handling update failure in Play 2.5 and ReactiveMongo
I have written simple rest API that will add music track data to mongodb.
I am able to write track successfully, however I would like to handle error case.
My code as below -
def saveTrack = Action.async(parse.json) {
import…

Pari
- 1,443
- 3
- 19
- 34
0
votes
1 answer
getting None.get when filling an HTML form from data from MongoDB in PlayFramework, scala, reactivemongo application
I am learning ReactiveMongo. In my application, I want to retrieve data from MongoDB and fill it in an HTML form.
Earlier my problem was that code wasn't compiling. I fixed it but now I am getting None.get instead of value from database.
The data I…

Manu Chadha
- 15,555
- 19
- 91
- 184
0
votes
1 answer
How to create a custom writer/reader that queries the DB?
I have a class Song and a class Album. My goal is to have two separate collections and keep a reference via BSONObjectID in the database, but in my code I want to map these IDs to their respective entities.
Here's my current model:
case class…

John Doe
- 271
- 2
- 17
0
votes
1 answer
The best way to convert Success into Failure depending on the value of Success
I use Play! Framework with ReactiveMongo plugin (versions 2.3 and 0.11 accordingly). And I have the next code which removes items from MongoDB collection and returns a number of affected items:
/**
* Removes all subscribers by subscription id
*…

Alexey Sirenko
- 452
- 3
- 12
0
votes
1 answer
Scala Play convert a request to JSON and write it to MongoDB
I'm using Play 2.5 and ReactiveMongo. It's a simple problem but I can't figure it out. I have a controller that receives a username and password from a view, I want to convert this request to a model of type UserModel and then convert this model to…

ChazMcDingle
- 635
- 2
- 10
- 18
0
votes
1 answer
Querying time field using ReactiveMongo and Play JSON
I am trying to the equivalent of this query using ReactiveMongo with Play Framework & JSON:
db.getCollection('people').find({'refreshed': {$gt: ISODate('2017-01-01')}})
I tried this:
def peopleFuture Future[JSONCollection]…

daphshez
- 9,272
- 11
- 47
- 65
0
votes
1 answer
Play ReactiveMongo JSON Serialization Generics
I have a problem using Play 2.5.x and ReactiveMongo Play. I am trying to create a Generic Repository and I have serious problems when serialize and deserialize objects to database. It always give me the following error: No Json deserializer found…

Marco Talento
- 2,335
- 2
- 19
- 31
0
votes
0 answers
Could not access type BSONElement in package reactivemongo.bson.package
Hi I am trying to compile a play framework application which uses the reactivemongo driver.
The ./activator compile works great on my dev machine but gives me the following error on a remote ubuntu box. The build.sbt is exactly the same in both…

summerNight
- 1,446
- 3
- 25
- 52
0
votes
1 answer
Inserting an object into Mongo database using Scala's ReactiveMongo driver
I am learning how to use Scala, MongoDB and the Play framework all together, and I have been looking at a demo project that's located here: https://github.com/jonasanso/play-reactive-mongo-db
However, I don't understand the syntax in the create()…

Calculus5000
- 427
- 6
- 17
0
votes
1 answer
Execute raw commands in a MongoDb collection from Play 2 using ReactiveMongo and JSONCollection
Hi I am using ReactiveMongo and Play, and I would like to be able to run a MongoDB command in a collection.
My collection is declared like that :
def thingsJSONCollection : Future[JSONCollection] =
database.map( connectedDb =>
…

Antonin
- 879
- 2
- 10
- 27
0
votes
1 answer
How to create custom ReactiveMongo Reader & Writer for object?
Let's say I have the following model:
case class Game(var _id: Option[BSONObjectID] = None,
name: String,
genre: Genre.Kind,
var created: Option[DateTime] = None,
var…

John Doe
- 277
- 3
- 14
0
votes
1 answer
add document with ReactiveMongo with specified _id
I'm trying to insert a new document with _id field specified in ReactiveMongo. But all my inserts are executed with Mongo default incremental objectId. Is there a way to specify _id during insert?
Here is my code.
case class MongoId($oid:…

Meisam Emamjome
- 508
- 5
- 15
0
votes
1 answer
ReactiveMongo common function
I have several functions like these:
import reactivemongo.play.json.collection.JSONCollection
def quotesFuture: Future[JSONCollection] = database.map(_.collection[JSONCollection]("quotes"))
1: def getByAuthor(author: String) = Action.async…

David Portabella
- 12,390
- 27
- 101
- 182
0
votes
1 answer
Return ReactiveMongo JSON in Play Framework
What is the fastest way to return JSON text from BSONArray?
I'm returning very big JSON document. Is it possible to omit processing Play JsValue
Now I'm returning like this:
val result:BSONArray = ....
Ok(Json.toJson(result))
I think faster would…

Michał Jurczuk
- 3,728
- 4
- 32
- 56
0
votes
0 answers
ReactiveMongo Scala DAO pattern
I have the following DAO, Service Object and Controller pattern in my Playframework project:
CredentialsDAO.scala:
def find(authType: AuthType.Value, authAccountId: String) =
collection.find(
Json.obj(Fields.AuthType → authType,
…

MojoJojo
- 3,897
- 4
- 28
- 54