I'm working on a project where we use mongodb 4.4 as our database. The problem is I have to make a query that is too complicated using mongo query language.
That's an exemple of the data in the database:
{
"neededQuantity": 100,
"auth": {
"groups": ["group-1"]
},
"createTime": "2022-02-03T14:17:25.809704600Z",
},
{
"neededQuantity": 120,
"auth": {
"groups": ["group-3"]
},
"createTime": "2022-02-02T14:17:25.809704600Z",
},
{
"neededQuantity": 150,
"auth": {
"groups": ["group-2","group-1"]
},
"createTime": "2022-02-01T14:17:25.809704600Z",
}
The query has to find the documents that have at least 1 element of the list auth.groups in common with an another list that is given as input.
If the input list is ["group-1"], the query result should be:
{
"neededQuantity": 100,
"auth": {
"groups": ["group-1"]
},
"createTime": "2022-02-03T14:17:25.809704600Z",
},
{
"neededQuantity": 150,
"auth": {
"groups": ["group-2","group-1"]
},
"createTime": "2022-02-01T14:17:25.809704600Z",
}
How can I do it?
Thank you very much in advance.