reactivemongo

required: spray.httpx.marshalling.ToResponseMarshallable Error

纵饮孤独 提交于 2019-12-08 04:00:23
问题 Hey im pretty new to Spray and reactive mongo . Im trying to return a list of result as json but i'm having some issue with converting the result to list of json. this is my model import reactivemongo.bson.BSONDocumentReader import reactivemongo.bson.BSONObjectID import reactivemongo.bson.Macros case class Post(id: BSONObjectID, likes: Long, message: String, object_id: String, shares: Long) object Post { implicit val reader: BSONDocumentReader[Post] = Macros.reader[Post] } the Mongo method

embedmongo with reactivemongo process does not exit

耗尽温柔 提交于 2019-12-08 02:39:36
问题 I am trying to do some tests using ScalaTest + embedmongo + reactivemongo but I fail. My first problem is that after a test mongod process does not shut down, I have this message in console: INFO: stopOrDestroyProcess: process has not exited and tests are paused till I kill the process manually. That happens even if body of my test is empty. I am running windows 8.1. The other issue is, that when I try to connect to db inside test using reactive mongo and insert anything to db I get this

ReactiveMongo FindAndModify Clarification

假如想象 提交于 2019-12-08 00:51:30
问题 I have a collection in my MongoDB database with say several keys. Now I want to update this collection with a new field. So here is what I have so far: def confirm(hash: String) = { val myDb = dbConn.db(dbName) val userCollection = myDb[BSONCollection]("user") val selector = BSONDocument(idKey -> BSONObjectID(hash)) val modifier = BSONDocument( "$set" -> BSONDocument("date" -> BSONString(now.toString)) // Line 1 ) val command = FindAndModify( userCollection.name, selector, Update(modifier,

Json Coast to Coast Play framework : Serializing Joda DateTime

半世苍凉 提交于 2019-12-07 19:30:18
问题 Hi all I am new to play framework, if someone knows of a better approach then mentioned below please let me know. So I have a model and Reads/Writes/Format for it case class Schedule (startDate: DateTime, endDate: DateTime) object ScheduleSerializers { val userDateFormatter = "dd/MM/yyyy HH:mm:ss" val nonImplicitUserFormatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss") implicit val jodaDateTimeReads = Reads.jodaDateReads(userDateFormatter) implicit val jodaDateTimeWrites = Writes

required: spray.httpx.marshalling.ToResponseMarshallable Error

五迷三道 提交于 2019-12-07 10:53:27
Hey im pretty new to Spray and reactive mongo . Im trying to return a list of result as json but i'm having some issue with converting the result to list of json. this is my model import reactivemongo.bson.BSONDocumentReader import reactivemongo.bson.BSONObjectID import reactivemongo.bson.Macros case class Post(id: BSONObjectID, likes: Long, message: String, object_id: String, shares: Long) object Post { implicit val reader: BSONDocumentReader[Post] = Macros.reader[Post] } the Mongo method def getAll(): Future[List[Post]] ={ val query = BSONDocument( "likes" -> BSONDocument( "$gt" -> 27))

Idiomatic way of getting a collection in ReactiveMongo

会有一股神秘感。 提交于 2019-12-07 07:27:26
I'm writing a Play/Scala application using Play 2.5.4 and ReactiveMongo. Based on this example , I'm getting the collection using class SettingStore( val mongo:ReactiveMongoApi) { def collection = mongo.db.collection[BSONCollection]("Settings") // more code... } However, db is now deprecated. The deprecation warning recommends I use database , but this one returns a Future so all operations have to be mapped over. Since ReactiveMongo's operations also return Future s, this seems redundant... what's to proper way of getting a collection? (or, am I missing something completely and Future[Future

Strange MongoError (with ReactiveMongo) when Play reloads application

折月煮酒 提交于 2019-12-07 06:04:42
问题 Very often, when Play reloads the application after a code change, I receive the following error: MongoError['The node set can not be reached! Please check your network connectivity.'] The MongoDB log looks like this: 2016-09-06T18:51:22.609+0200 I NETWORK [initandlisten] waiting for connections on port 27017 2016-09-06T18:53:49.916+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60559 #1 (1 connection now open) 2016-09-06T18:53:51.185+0200 I NETWORK [initandlisten]

Reactivemongo serializing a map into a BSONDocument

痞子三分冷 提交于 2019-12-06 09:29:12
I defined BSONDocumentWriter s 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 there was a Salat-like solution for that). However, I can't seem to be able to do the same for a Map[String,Any] (where the values can be of type numeric, date or string). I found a code example that defines a generic writer (and reader) for a map: implicit def MapWriter[V](implicit vw: BSONDocumentWriter[V]): BSONDocumentWriter[Map[String, V]] =

ReactiveMongo FindAndModify Clarification

自作多情 提交于 2019-12-06 04:50:13
I have a collection in my MongoDB database with say several keys. Now I want to update this collection with a new field. So here is what I have so far: def confirm(hash: String) = { val myDb = dbConn.db(dbName) val userCollection = myDb[BSONCollection]("user") val selector = BSONDocument(idKey -> BSONObjectID(hash)) val modifier = BSONDocument( "$set" -> BSONDocument("date" -> BSONString(now.toString)) // Line 1 ) val command = FindAndModify( userCollection.name, selector, Update(modifier, fetchNewObject = true) ) myDb.command(command) .map { user => // Line 2 Right(bidList) }.recover { case

embedmongo with reactivemongo process does not exit

佐手、 提交于 2019-12-06 04:13:15
I am trying to do some tests using ScalaTest + embedmongo + reactivemongo but I fail. My first problem is that after a test mongod process does not shut down, I have this message in console: INFO: stopOrDestroyProcess: process has not exited and tests are paused till I kill the process manually. That happens even if body of my test is empty. I am running windows 8.1. The other issue is, that when I try to connect to db inside test using reactive mongo and insert anything to db I get this exception: reactivemongo.core.errors.ConnectionNotInitialized: MongoError['Connection is missing metadata