New with MongoDB so still learning the ropes. I am currently writing an aggregation pipeline. Not to get into specifics (I can write them later if needed) but I am using $map and inside the map I am using $getField which uses the variable set in the $map step of the pipeline.
I use { $literal: "$$field.field_id"} for field which doesn’t seem to work.
Am I using it wrong and can $literal accept a variable from map and is there a workaround ?
It seems that my issue isn’t that I am using variable in $literal but instead that I am trying to use $getField with a variable field name. Still not sure what the workaround for this is.
I am not sure what you expect when using $literal but $literal means that what ever follows IS NOT an expression so none of the $ or $$ will be interpreted or evaluated.