Wondering if it is possible to allow $unwind to accept expression which resolves to array.
Hi Shiv,
The $unwind stage accepts a field path
parameter or an expression that resolves into a field path.
As suggested by Apaine, you could try using $project first, for example:
db.collection.aggregate([{$project:{"tmp":{$objectToArray:"$foo"}}},
{$unwind:"$tmp"}
]);
Regards,
Wan.
Actually my question( more of enhancement request)
Hi Shiv,
The idea of aggregation is to have re-usable building blocks for different operations.
Although if you feel strongly about the request, please feel free to open a SERVER ticket on MongoDB issue tracking system.
Please make sure to include a detailed use case information and example(s) in the ticket description.
Kind regards,
Wan.