How do I make mongodb select fields specified in an object in an aggregate pipeline?

Hi, I would like to select only the fields in an object.

This object with the fields to be selected is returned from a $function, however mongo dB is treating it as a literal how to I force it to perform the projection and stop setting the field to the literal object returned from the function.

Hi @John_Kennedy_Kalu and welcome to the MongoDB Community forums! :wave:

It would be helpful to see sample documents that you are working with and any code that is having problems. Without seeing what you’re seeing it’s really hard to understand the problem and provide any suggestions.