Asynchronous & Non-Blocking Scala Driver for MongoDB
Questions tagged [reactivemongo]
508 questions
0
votes
0 answers
MongoDB: How to deal with invalid ObjectIDs
Here below is my code to find a document by ObjectID:
def find(selector: JsValue, projection: Option[JsValue], sort: Option[JsValue],
page: Int, perPage: Int): Future[Seq[JsValue]] = {
var query =…

j3d
- 9,492
- 22
- 88
- 172
0
votes
2 answers
Play 2.2 EssentialAction With Futures
I'm trying to implement an authentication mechanism similar to this example:
def HasToken(action: String => EssentialAction): EssentialAction = EssentialAction { requestHeader =>
val maybeToken =…

James Cowhen
- 2,837
- 3
- 24
- 32
0
votes
1 answer
ReactiveMongo: find() does not return anything when seeking by a field different that _id
Here below are four statements that should return the same document, i.e. the one with id 52dfc13ec20900c2093155cf and email me@gmail.com:
val collection =…

j3d
- 9,492
- 22
- 88
- 172
0
votes
1 answer
ReactiveMongoDB plugin use id in JSONCollections
I described model as case class WorkAreaType(name: String) and findAll method
object WorkAreaType {
import system.db.Mongo.JsonFormats._
def findAll = Await.result(Mongo.workAreaTypes.find(Json.obj()).cursor[WorkAreaType].collect[List](), 3…

Artem
- 505
- 5
- 22
0
votes
1 answer
ReactiveMongoDB plugin with recursive structure
I use Play Framework 2.2.1 and reactivemongo with plugin "org.reactivemongo" %% "play2-reactivemongo" % "0.10.2"
My model:
package models
import system.db.Mongo
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import…

Artem
- 505
- 5
- 22
0
votes
1 answer
ReactiveMongo: How to use FindAndModify with JSON
When I update a document in MongoDB, I usually proceed like this:
Find the current document and get the version number
Increase the version number and save the new document
Save the old document in a vermongo collection
Here is my solution – I'm…

j3d
- 9,492
- 22
- 88
- 172
0
votes
1 answer
ReactiveMongo custom BSONDocument{ Reader, Writer }
I'm new with ReactiveMongo and I want to create a custom document reader/writer for one object but I'm getting this error
type mismatch; found …

Rodrigo Cifuentes Gómez
- 1,304
- 2
- 13
- 28
0
votes
1 answer
Writing BSONBinary to MongoDB fails with reactivemongo
I am trying to save data into the database of a binary type.
The call is:
val query = BSONDocument("_id" -> binId)
val update = BSONDocument(
"$inc" -> BSONDocument(
"fieldA" -> 1L
))
coll.update(query, update, GetLastError(), upsert =…

Alex K
- 854
- 9
- 16
0
votes
0 answers
How do I set $maxScan?
I have a query like so.
import play.modules.reactivemongo.json.BSONFormats._
def collection: JSONCollection = db.collection[JSONCollection]("persons")
val q = Json.obj("foo" -> "bar")
collection.find(q).cursor[JsObject].collect[Seq](500)
How do I…

Gabriel
- 1,679
- 3
- 16
- 37
0
votes
1 answer
ReactiveMongo: How to deserialize a list into an Option
Here below is a case class that represents an user, and its companion object provides a BSONDocumentWriter and BSONDocumentReader to serialize/deserialize to/from BSON:
case class User(
id: Option[BSONObjectID],
name: String,
addresses:…

j3d
- 9,492
- 22
- 88
- 172
0
votes
3 answers
How to parse this "pretty" BSON in Scala?
In our project we are using Scala and Reactivemongo. (I'm very new to both)
When you print to the console a "pretty" Bson, it looks like this:
{ _id: BSONObjectID("52b006fe0100000100d47242"),
desc:…

Shany Tooper
- 3
- 1
- 2
0
votes
1 answer
how to implement validation in case class used as form (using Json.fromJson)
i am using TypeSafe activator template as a basis for an app (play+reactivemongo+knockoutJS).
i am trying to create a user, and while doing it i want to validate that the country they provided is already in the DB. but due to the structure of the…

Ehud Kaldor
- 753
- 1
- 7
- 20
0
votes
0 answers
When do I use null value for a field and when should I not write the field in MongoDB?
I'm currently playing around with reactivemongo and mongodb and I found something I do not know how to handle.
Let say I have an case class UserInfo:
case class UserInfo(override var _id: Option[BSONObjectID] = None,
firstName:…

jakob
- 5,979
- 7
- 64
- 103
0
votes
3 answers
Handling errors in ReactiveMongo
I am working on a simple RESTful web service using Play Framework 2.1.5 and ReactiveMongo 0.9 using ReactiveMongo Play plugin. It has been a long time since I used Play Framework for the last time. I am trying to insert a document using:
def create…

Karel Horak
- 1,022
- 1
- 8
- 19
0
votes
1 answer
Finding a possible slug in mongo using reactivemongo
I am trying to find an available slug in mongodb using Play2 and reactivemongo.
I came up with the following recursive method.
private def findSlug(base: String, index: Int): String = {
val slug: String = Slug({
base + "-" + index
…

DanielKhan
- 1,190
- 1
- 9
- 18