I have this query:
db.getCollection('lojasDisponiveis').aggregate( [
{ $group: { _id: { codigosLojas: "$codigosLojas", codigoUrl: "$codigoUrl" }}}
] );
The problem:
For each store or group of stores, I have a code that goes into a url parameter. However, some stores have different urls (different codes) that carry the same information (the same stores (171 and 232).
{
"_id": {
"codigosLojas": [
171, 232
],
"codigoUrl": 676
}
}, {
"_id": {
"codigosLojas": [
171, 232
],
"codigoUrl": 675
}
}, {
"_id": {
"codigosLojas": [
10
],
"codigoUrl": 11
}
}, {
"_id": {
"codigosLojas": [
21
],
"codigoUrl": 2
}
}
In this example, the two urls with codes 676 and 675 have the same information. I need only one.
What I need:
If there are the same stores with different Url codes, bring only one set of information (from a url only). For example, this return:
{ "_id" : { "codigosLojas" : [ 171, 232 ], "codigoUrl" : 675 } }
{ "_id" : { "codigosLojas" : [ 10 ], "codigoUrl" : 11 } }
{ "_id" : { "codigosLojas" : [ 21 ], "codigoUrl" : 2 } }