I'm trying to craft a new Date value into a projection within a reactivemongo aggregate pipeline.
I have seen other examples where people create this within the mongo shell, like this:
db.runCommand({
"aggregate" : "collectionName", "pipeline": [
{ $project: { exampleDate: new Date() } }
]
})
The problem lies in the new Date()
. With reactivemongo the projection would be a Project object:
Project( ("exampleDate", BSONValue) )
where the BSONValue can be a BSONString. But that results in mongoDB ignoring such string, since the result will be:
{ "aggregate" : "collectionName", "pipeline": [ { $project: { exampleDate: "new Date()" } } ] }
Is there any way to insert the new Date()
without the quotes?
P.S.: I've also tried using BSONDateTime(0)
But this results in:
{ $date: 0 }
Which makes mongoDB throw an invalid $date
operator exception.