Asynchronous & Non-Blocking Scala Driver for MongoDB
Questions tagged [reactivemongo]
508 questions
0
votes
0 answers
Catch a reactivemongo exception when the DB is down
I have a function saveToDB() that calls another function db.writeDocument() in another class called DB.scala. The saveToDB() function receives a JSON message and sends it to the writeDocument() and expects a future to be returned.
So, in the code…

summerNight
- 1,446
- 3
- 25
- 52
0
votes
1 answer
Misunderstanding error about ReactiveMongo
I defined the following class which I want to modelize :
case class Record(
recordKey: String,
channels: Map[String, Channel],
)
object Record {
implicit val RecordFormat =…

alifirat
- 2,899
- 1
- 17
- 33
0
votes
2 answers
Get back documents from MongoDB stored in UTC format
I have documents that have dates stored in MongoDB in the UTC format: 2016-01-28T01:00:00Z where Z represents the UTC time.
What I am trying to do is find all documents, for which the date has not expired (date_stored_in_DB > Today's Date). However…

summerNight
- 1,446
- 3
- 25
- 52
0
votes
2 answers
Instantiate a val from a given @inject class
How do I instantiate an object from this class? I have another class where I would like to use the MongoUtils class as defined below. This class is from reactivemongo
package controllers
import javax.inject.Inject
import…

summerNight
- 1,446
- 3
- 25
- 52
0
votes
0 answers
Play Scala ReactiveMongo like query
Hello i have problem i got repo and controler witch returns all object in colection but i wannt to do search in colection in "adress" field my data looks like "adres" "Some adres " booknr "booknr" i wantt to create rest returns items that have some…

Łukasz Biel
- 11
- 1
- 2
0
votes
1 answer
DatabaseException with Scala Play 2.4 ReactiveMongo
I created a simple Play-Scala application to test ReactiveMongo and encountered a strange exception. These are the steps:
Create a new play-scala app
activator new test-mongo
Configure application.conf and build.sbt according to this link…

Joseph Hui
- 573
- 6
- 11
0
votes
1 answer
ReactiveMongo findOne gives ambiguous implicit values
My relevant imports are:
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.json.Jsonimport play.modules.reactivemongo.json._
import play.modules.reactivemongo.ReactiveMongoApi
import…

user1244924
- 25
- 5
0
votes
1 answer
ReactiveMongo 0.11.9 throws No primary node is available while connecting to mongodb 3.0.4
I simply have a reactivemongo (version : 0.11.9) insertion query as below,
class MongoInsertQuery extends Query {
val DbName = "events-db"
val CollectionName = "EventStream"
val driver = new MongoDriver
val connection =…

prayagupa
- 30,204
- 14
- 155
- 192
0
votes
1 answer
How to ensure successful authentication with scala reactivemongo play
I am using reactivemongo to connect to MongoDB.
val connection: MongoConnection = driver.connection(hosts, options = conOpts, authentications = List(credentials))
val db = connection(database)
val collection = db(collection)
val resultData =…

david
- 309
- 1
- 4
- 15
0
votes
1 answer
Writing ScalaTest for ReactiveMongoApi in Playframework 2.4?
I am trying to start writing test for mongodb in my play application.
It seems that I can not get it working because the connection is shutdown before the save is executed.
Here are the results
[info] UserDaoMongoSpec:
[info] UserDao
[info] -…

agusgambina
- 6,229
- 14
- 54
- 94
0
votes
1 answer
No Json serializer as JsObject found for type model.User. Try to implement an implicit OWrites or OFormat for this type
I'm using Play framework with Scala and Reactive Mongo to save an object into my mongodb database. Following this http://reactivemongo.org/releases/0.10/documentation/bson/usage.html I came up with the following code:
import java.util.Date
import…

redwulf
- 1,317
- 3
- 13
- 35
0
votes
0 answers
Return attribute as list of case class
Lets say I have
case class Foo(_id: BSONObjectID, bars: Set[Bar])
case class Bar(_id: BSONObjectID, name: String)
How can I get the bars of a specific Foo using projections?
I tried (omitting the declaration of the handlers)
val bars:…

Quarktum
- 669
- 1
- 8
- 26
0
votes
0 answers
Update nested fields in Mongodb
I have a Json for vendor:
{
"id": 1,
"contact": {
"address": "abc",
"phone": "123456"
}
}
If the update is {"contact": {"address":"xyz"}}, the address should be updated to xyz, and phone is still there, i.e. not deleted.
I…

Luong Ba Linh
- 802
- 5
- 20
0
votes
1 answer
ReactiveMongo query failing to paginate
Having some issues getting ReactiveMongo 0.11 to paginate my query. The behavior is that it is returning all results, instead of the page-by-page results.
Here's my query:
def listConvos(userId: String, page: Int, pageSize: Int) = {
val query =…

crockpotveggies
- 12,682
- 12
- 70
- 140
0
votes
2 answers
Need help handling IllegalArgumentException in reactivemongo
The below code tries to get document by ID using Reactivemongo. However, I don't know how to deal with the IllegalArgumentException thrown when the ID is wrong!
Tried the below code but the compiler is not happy with case _ =>…

Mutaz
- 547
- 4
- 12