I'm trying to perform a ReactiveMongo aggregate
call with a cursor, to avoid the Result Size restrictions.
def sumPerUser(appId: String, date: DateTime): Future[Seq[UserImpressionSums]] = {
import collection.BatchCommands.AggregationFramework._
collection.aggregate(
Match(BSONDocument(APP_ID -> appId, DATE_CREATED -> BSONDocument("$gte" -> BSONDateTime(date.getMillis)))),
List(Project(BSONDocument(USER -> 1, DATE_CREATED -> 1, IP -> 1, CAMPAIGN_ID -> 1, "imp" -> BSONDocument("$literal" -> 1) )),
Group(BSONDocument(USER -> "$user", IP -> "$ip", CAMPAIGN_ID -> "$campaign_id"))
("totalImps" -> SumField("imp"), DATE_CREATED -> First(DATE_CREATED)),
Sort(Ascending(DATE_CREATED))
), false, true, Some(Cursor(100)))
.map(_.result[UserImpressionSums])
}}
The code compiles correctly, but throws an exception on execution:
reactivemongo.api.commands.bson.DefaultBSONCommandError: CommandError[code=14, errmsg=cursor field must be missing or an object, doc: {
ok: BSONDouble(0.0),
errmsg: "cursor field must be missing or an object",
code: BSONInteger(14)
}]
Any ideas why this might be happening?