Hi there,
I have a golang project, which uses mongo driver (“go.mongodb.org/mongo-driver/mongo”).
My collections live in Atlas free tier cluster. They have a collection like below.
I want to filter documents by company name and get elements in a specific index range of the nested array “employees”. (For example, getting only first and second employees who works for ABC company)
How can I do that by Mongo query and golang driver?
[
{
"_id": "hoge",
"companyname": "ABC",
"empoloyees": [
{
"name": "John Doe",
"email": "john@ABC.com"
},
{
"name": "Jone Doe",
"email": "jone@ABC.com"
}
]
},
{
"_id": "fuga",
"companyname": "XYZ",
"empoloyees": [
{
"name": "Tom Cat",
"email": "john@XYZ.com"
},
{
"name": "Dazy Dog",
"email": "jone@XYZ.com"
}
]
}
]