Asynchronous & Non-Blocking Scala Driver for MongoDB
Questions tagged [reactivemongo]
508 questions
4
votes
1 answer
Project a new Date into aggregation pipeline using reactivemongo
I'm trying to craft a new Date value into a projection within a reactivemongo aggregate pipeline.
I have seen other examples where people create this within the mongo shell, like this:
db.runCommand({
"aggregate" : "collectionName", "pipeline":…

Bilk
- 418
- 6
- 19
4
votes
2 answers
Transform Enumerator[T] into List[T]
I am integrating an application using ReactiveMongo with a legacy application.
As, I must maintain legacy application interfaces at some point I must block and/or transform my code into the specified interface types. I have that code distilled down…

bearrito
- 2,217
- 1
- 25
- 36
4
votes
1 answer
ReactiveMongo : How to write macros handler to Enumeration object?
I use ReactiveMongo 0.10.0, and I have following user case class and gender Enumeration object:
case class User(
_id: Option[BSONObjectID] = None,
name: String,
gender: Option[Gender.Gender] =…

SBotirov
- 13,872
- 7
- 59
- 81
4
votes
2 answers
Searching text in MongoDB with ReactiveMongo
I have some documents in MongoDB like the following:
{
"no" : "ABC123",
"description": "The brown fox jumped over the lazy dog"
}
I want to be able to search through all such documents in the collection and return all documents which contain,…

saintlyRook
- 475
- 1
- 4
- 13
4
votes
3 answers
How to convert an UUID into a MongoDB oid
Given an java.util.UUID generated like this...
import java.util.UUID
val uuid = UUID.randomUUID
... is it possible to convert it into a MongoDB ObjectID and preserve uniqueness? Or shall I just set _id to the UUID value?
Of course, the best…

j3d
- 9,492
- 22
- 88
- 172
4
votes
1 answer
ReactiveMongo: How to use projection
I'm trying to filter out the password field when querying a document from MongoDB with ReactiveMongo:
val projection = Json.obj("password" -> 0)
def find(selector: JsValue, projection: Option[JsValue]) = {
val query =…

j3d
- 9,492
- 22
- 88
- 172
4
votes
2 answers
Creating a unique index for a collection in reactivemongo
Looking at the MongoDB documentation it looks like you can ensure an index is created for a collection at application runtime using a command that looks something like this:
db.myCollection.ensureIndex({'my-col': 1}, {unique: true})
I can't find…

Jordan
- 1,599
- 4
- 26
- 42
4
votes
1 answer
How to represent a GeoJSON point in a ReactiveMongo model?
In order to do geospatial queries in MongoDB a document with a location (with a 2d or 2dsphere geospatial index) should look something like this:
{
_id: …,
loc: {
type: "Point",
coordinates: [ , ]
…

Nick
- 2,576
- 1
- 23
- 44
4
votes
3 answers
Cannot add ReactiveMongo to Play-Framework
ers,
I am having troubles with integrating the ReactiveMongo within the Play framework. My build.sbt
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.9"
)
When I try to run the server with the play run command I get…

Fokko Driesprong
- 2,075
- 19
- 31
4
votes
1 answer
Asynchronous input validators in Play2
I am using play2.1 and I need a validator which checks if a given name is already taken or not in MongoDB. I am using reactive mongo which is an asynchronous MongoDB driver, although my question doesn't depend on this library.
Generally speaking, I…

Ali Salehi
- 6,899
- 11
- 49
- 75
4
votes
1 answer
Error: "could not find implicit value for parameter readFileReader" trying to save a file using GridFS with reactivemongo
I am trying to save an attachment using reactivemongo in Play 2.1 using the following code:
def upload = Action(parse.multipartFormData) { request =>
request.body.file("carPicture").map { picture =>
val filename = picture.filename
val…

G A
- 571
- 3
- 6
- 18
3
votes
0 answers
ReactiveMongo Pagination with Count
I am trying to implement Pagination with Reactive Mongo.
def get(page: Int, pageSize: Int, filter: JsObject = Json.obj()): Future[Seq[Thing]] = {
val actualPage = if(page > 1) page else 1
collection
.find(filter)
…

Eduardo
- 6,900
- 17
- 77
- 121
3
votes
0 answers
Scala ReactiveMongo: Channel not found on minor internet outage
Reactive Mongo stops on minor internet outage and doesn't restore, neither play stops, just subsequent queries get these repeated exception saying connection 10/1 but channel not found.
This is mentioned as GitHub issue as well, but no solution is…

Ravinder Payal
- 2,884
- 31
- 40
3
votes
0 answers
Inherited parse method conflict in scala
I'm working through some compilation errors (in Scala / Play Framework) and one I can't resolve is a conflict error. This is the error:
class Games inherits conflicting members:
[error] method parse in trait BaseControllerHelpers of type =>…

jesus g_force Harris
- 485
- 6
- 16
3
votes
2 answers
How do I set `skip` (offset) for reactivemongo mongodb driver?
I need to skip a number of documents (offset) from a query, and only return limit number of documents that go after. I know the following naive approach:
collection.find(BSONDocument())
…

VasiliNovikov
- 9,681
- 4
- 44
- 62