I wonder if there is the way to $match
in mongo to find exact dict in list of dicts
I have documents with this fields
{
_id: ObjectId("6644d9860e3b38f3dd724241"),
fields: {
allowed_urls: [
{
url: "/my_url/",
method: "POST"
},
{
url: "/my_url/",
method: "GET"
}
]
}
}
And I am filtering my documents like this to find exact document where document has dict with filter params
[{'$match': {'fields.allowed_urls.url': '/my_url/', 'fields.allowed_urls.method': 'POST'}}]
But for some reason if document looks like this
{
_id: ObjectId("6644d9860e3b38f3dd724241"),
fields: {
allowed_urls: [
{
url: "/another_url/",
method: "POST"
},
{
url: "/my_url/",
method: "GET"
}
]
}
}
Mongo will find him as well bcs this document has my_url and POST but i want to find document with only exact params in 1 dict. I was trying to do something like fields.allowed_urls.$.method
but that does not help