I am creating a projection and am trying to figure out how to convert a mongoid to a timestamp IN THE projection. It is apparent that we can use .getTimestamp() to just get the timestamp of a mongoid, but I don't know how to make a new field in a projection. I tried this and it fails.
db.collection.aggregate(
[
{$unwind:
"$arrayToUnwind"
},
{$project:
{
timeOfId: "$_id".getTimeStamp()
}
},
]
)
Any help please?! I want to make an ISO timestamp out of this projection.
Thanks!