I have an user object that looks like that
{
"_id": ObjectId("string"),
...
"clients": [
{
"_id": ObjectId("client1_string"),
...
},
{
"_id": ObjectId("client2_string"),
...
},
]
}
I wanna get this result
{
"_id": ObjectId("client1_string"),
...
}
Anything I try returns me the user object that includes that client, but all I want is the client himself... what am I doing wrong? I have already tested couple of codes found from different questions and that is the last try which brings the same result.
users.findOne(
{
'_id': ObjectId(user_id)
},
{
'clients': { $elemMatch: { '_id': ObjectId(client_id) }
}
})