Consider below json object as attribute collection
{
"_id" : ObjectId("5912f2d9d5dcab2bf5ed4572"),
"name" : "design",
"hybris_name" : "design",
"type" : "predefin_values",
"options" : [
{
"english_text" : "Animal Print",
"arabic_text" : "مركب",
"template_id" : [
1,
2,
4
]
},
{
"englis_text" : "Straight",
"arabic_text" : "بوي فريند",
"template_id" : [
1,
3
]
}
]
}
{
"_id" : ObjectId("59130618d5dcab2bf5ed4573"),
"name" : "fit",
"hybris_name" : "",
"fit" : "predefin_values",
"options" : [
{
"englis_text" : "Slim",
"arabic_text" : "واسع",
"template_id" : [
1,
3
]
},
{
"englis_text" : "Straight",
"arabic_text" : "بوي فريند",
"template_id" : [
1
]
},
{
"englis_text" : "bend",
"arabic_text" : "بوي فريند",
"template_id" : [
1
]
}
]
}
Now I want the options to specific template id Let's say I want the options for template id 3 my result set should look like below.
{
"_id" : ObjectId("5912f2d9d5dcab2bf5ed4572"),
"name" : "design",
"hybris_name" : "design",
"type" : "predefin_values",
"options" : [
{
"englis_text" : "Straight",
"arabic_text" : "بوي فريند",
"template_id" : [
1,
3
]
}
]
}
{
"_id" : ObjectId("59130618d5dcab2bf5ed4573"),
"name" : "fit",
"hybris_name" : "",
"fit" : "predefin_values",
"options" : [
{
"englis_text" : "Slim",
"arabic_text" : "واسع",
"template_id" : [
1,
3
]
}
]
}
How to write the mongo query for this?