I am using Play2 framework with play-reactivemongo and casbah. I have the following Code:
def geofence(lat:Float, lon:Float, rad:Float) = Action { request =>
val mongoColl = MongoConnection()("db")("geofence")
mongoColl.ensureIndex(MongoDBObject("loc" -> "2dsphere"))
val geo = MongoDBObject(
"loc" -> MongoDBObject(
"$nearSphere" -> MongoDBObject(
"type" -> "Point",
"coordinates" -> MongoDBList( 52.431929,
13.506188)
),
"$maxDistance" -> 10000 ))
val geoEvents=mongoColl.find(geo)
println(geoEvents)
Ok(geoEvents)
}
I send a http request to the server. Depends on the parameter I would like to find all datas in my database. The problem is with mongoColl.find I get only the MongoCursor and I get an error by Ok(geoEvents)
Cannot write an instance of Option[mongoColl.T] to HTTP response. Try to define a Writeable[Option[mongoColl.T]]
Q:How can I convert the val geoEvents to json for response?
Thanks