Remove all result Aggregate mongodb array

Asked

Viewed 57 times

1

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

{
"_id" : ObjectId("58862a838f3e2721f8d920cc"),
"total" : [ 
    [], 
    [], 
    [ 
        ISODate("2017-09-07T00:00:00.000Z")
    ], 
    [], 
    [], 
    [], 
    []
]}

1 answer

0

How I solved the problem I hope you help 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]
                                         }
                                    }
                                }

                            }
                        }

                    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.