Having document in collection test as follow:
{a:1, list:[{lang:"en", value:"Mother"}, {lang:"de", value:"Mutter"}] }
{a:2, list:[{lang:"en", value:"Iddqd"}] }
I would like build query that tries to match list.value to selected language, but if it absent then return any-available-item of list, so for example above and for query language de i need get $projection as:
{a:1, label:"Mutter"},
{a:2, label:"Iddqd"} //since no label matched 'de' let's select any available
Server version: MongoDB 3.2+
{a:2, label:"Iddqd"}for the second document?