Find value in array

my documents have a field

extensionSV= [
{‘system’: ‘rfrnc_yr’, ‘value’: ‘0003’},
{‘system’: ‘dual_01’, ‘value’: ‘AA’},
{‘system’: ‘dual_02’, ‘value’: ‘AA’},
{‘system’: ‘dual_03’, ‘value’: ‘AA’},
{‘system’: ‘dual_04’, ‘value’: ‘AA’},
{‘system’: ‘dual_05’, ‘value’: ‘AA’},
{‘system’: ‘dual_06’, ‘value’: ‘AA’},
{‘system’: ‘dual_07’, ‘value’: ‘AA’},
{‘system’: ‘dual_08’, ‘value’: ‘AA’},
{‘system’: ‘dual_09’, ‘value’: ‘AA’},
{‘system’: ‘dual_10’, ‘value’: ‘AA’},
{‘system’: ‘dual_11’, ‘value’: ‘AA’},
{‘system’: ‘dual_12’, ‘value’: ‘AA’}

further in pipeline I need to use a
var value = ?? (where system==dual_09),
how can i access array values in that way

If that represents your database


If that represents a field, mongodb traverses the arrays:


Or what exactly are you trying to achieve?

in project stage we need a new key-value, added at document level which is ‘rfrnc_yr’ : ‘0003’ or ‘dual_03’ : ‘AA’

As of now these exist in the array

Add a complete sample please:

  • Input document
  • Expected output

Then we can try to write a pipeline.