I’m trying to come up with an aggregation pipeline that will allow me to obtain some information from an enumerations
collection which has a data structure of { _id, name, value }
My current document structure is as follows…
{
name: "",
description: "",
events: [
{ actionType: ObjectId('...'), targetType: ObjectId('...') },
{ actionType: ObjectId('...'), targetType: ObjectId('...') }
]
}
Within the events
array I need to take the fields and look them up against the enumeration
collection and obtain the value
of the looked-up document.
I can’t figure out how to do a $lookup for these though and replace the values in the arrays, the end result would be something like…
{
name: "",
description: "",
events: [
{ actionType: 1, targetType: 64 },
{ actionType: 8, targetType: 128 }
]
}