per @cmgchess -
This can all be done in two steps:
{
_id: 1,
categories: [123, 234],
// other fields
}
$lookup
(without unwinding){
"_id": 1,
"categories": [
{
"_id": 123,
"value": "Category name"
},
{
"_id": 234,
"value": "Other category name"
}
],
// other fields
}
$set
using $map
// operation:
{
$set: {
categories: {
$map: {
input: "$categories",
as: "category",
in: "$$category.value"
}
}
}
}
// result:
{
"_id": 1,
"categories": [
"Category name",
"Other category name"
],
// other fields
}
paydirt. :)