I have a mongo collection where i have below structure:
{
"feature":"abc",
"translations"[
{
"lang":"en",
"text":"This is my text in english"
},
{
"lang":"de",
"text":"This is my text in german"
}
]
},
{
"feature":"cde",
"translations"[
{
"lang":"en",
"text":"This is my text in english"
}
]
}
Now, i want to write query to return default language "en" text if particular language ie., de text not found for a particular feature. If both language texts present, only "de" lang text need to be returned and "en" need to be ignored.
I tried with $or
or $in
, but these are giving both lang texts if present for a feature. I'm okay to do minimal changes to mongo document structure if required for better results.