Remove all array from result aggregate mongodb

1

I have the following total array I need to pick only those that have date.

{
"_id" : ObjectId("58862a838f3e2721f8d920cc"),
"total" : [ 
    [], 
    [], 
    [ 
        ISODate("2017-09-07T00:00:00.000Z")
    ], 
    [], 
    [], 
    [], 
    []
]}
    
asked by anonymous 28.09.2017 / 21:18

1 answer

0

As I solved the problem I hope it helps someone.

                        "feriados": {
                        $let: {
                            vars: { 
                              varin:{
                                   $map: {
                                        input: db.feriados.distinct('data', { 'status': true }),
                                        as: 'feriado',
                                        in: {
                                           "$not": [{ "$anyElementTrue": { 
                                                    $filter: {
                                                        input: [{ 
                                                            $cond: [{ $gte: [ISODate(), '$$feriado'] }, '$$feriado', 0] 
                                                         }],
                                                        as: "item",
                                                        cond: {
                                                            $lte: ['$aulaGrupo.dt_inclusao', '$$item']
                                                        }

                                                    }
                                                }
                                            }]
                                        }
                                    }
                                }
                            },
                            in: {
                                '$sum': {
                                    "$map": {
                                        "input": '$$varin',
                                        "as": "el",
                                        "in": { 
                                              '$cond': [{'$eq': [ "$$el", false ] }, 1, 0]
                                         }
                                    }
                                }

                            }
                        }

                    }
    
01.10.2017 / 01:39