If I sort the results of an aggregation query can I access the documents position in the results? This would be used to perform a calculation inside $project instead of returning the results and iterating over them.
The desired outcome where document position would be 0, 1, 2 etc:
db.trips.aggregate([
{ $match: { driver: "xx" } },
{ $sort: { "start.time": -1 } },
{ $project: {
_id: 1,
driver: 1
document_position: ____
} }
])