reactivemongo

How to use ReactiveMongo + JSON aggregation framework in Play Framework?

*爱你&永不变心* 提交于 2019-12-02 06:23:54
I need to utilize MongoDB's aggregation framework using ReactiveMongo. I only find this example which uses BSON. I would like to use JSON so I changed the code to : def populatedStates(col: JSONCollection) = { import col.BatchCommands.AggregationFramework.{AggregationResult, Group, Match, SumField} val res: Future[AggregationResult] = col.aggregate( Group(JsString("$state"))("totalPop" -> SumField("population")), List(Match(JSONDocument("totalPop" -> JSONDocument("$gte" -> 10000000L))))) res.map(_.firstBatch) } But there's no "JSONDocument" type. What would be the correct way to finish this

Best way to store/get values referenced from a list in Mongo/RectiveMongo?

最后都变了- 提交于 2019-12-02 03:54:03
问题 I have a quite common use case - a list of comments. Each comment has an author. I'm storing the reference from a comment to the author using a reference, since an author can make multiple comments. Now I'm working with ReactiveMongo and want to try to keep the database access asynchronous, but in this case, I don't know how. I do an asynchronous access to the database, to get the comments, but then for each comment I have to get the author, and until now the only way I know is to loop

Best way to store/get values referenced from a list in Mongo/RectiveMongo?

别等时光非礼了梦想. 提交于 2019-12-02 00:57:21
I have a quite common use case - a list of comments. Each comment has an author. I'm storing the reference from a comment to the author using a reference, since an author can make multiple comments. Now I'm working with ReactiveMongo and want to try to keep the database access asynchronous, but in this case, I don't know how. I do an asynchronous access to the database, to get the comments, but then for each comment I have to get the author, and until now the only way I know is to loop through the comments and get the user synchronously: val userOption:Option[JsObject] = Await.result

No Json serializer as JsObject found for type play.api.libs.json.JsObject

旧街凉风 提交于 2019-11-26 09:45:22
问题 I have the following code that works in a console app when referencing \"org.reactivemongo\" %% \"play2-reactivemongo\" % \"0.10.5.0.akka23\" when I update the reference to \"org.reactivemongo\" % \"play2-reactivemongo_2.11\" % \"0.11.0.play23-M3\" I get: No Json serializer as JsObject found for type play.api.libs.json.JsObject. Try to implement an implicit OWrites or OFormat for this type. import org.joda.time.DateTime import reactivemongo.bson.BSONObjectID import play.modules.reactivemongo