Consider the following (simplified) example:
{
_id: 1,
name: "Andrew",
role: "ATT",
Sesons: [
{
year: "2018-2019",
age: 20,
goals: 10
},
{
year: "2019-2020",
age: 21,
goals: 101
}]
}
{
_id: 2,
name: "Paul",
role: "DF",
Sesons: [
{
year: "2018-2019",
age: 15,
goals: 102
},
{
year: "2019-2020",
age: 16,
goals: 1
}]
}
How can I get this specific result from a query, based on {"Seasons.year": "2019-2020"} for example ?
{_id: 2, name: "Paul", role: "DF", Seasons: {age: 16}}
And how can I get this result from a query by getting an entire embedded document?
{_id: 2, name: "Paul", role: "DF", Seasons: {year: "2018-2019", age: 16, goals: 1}}
Thank you so much! I apologize for the question, perhaps, not correctly formatted, but it is my first question about Stack Overflow.