I need to filter this query so that documents with value Undefined
does not appear. Currently, my code shows this result:
db.getCollection("actors").find({})
db.actors.aggregate([
{
$group: { _id: "$cast", Peliculas: { $sum: 1 } },
},
{ $sort: { Peliculas: -1 } },
{ $limit: 2 }
])
I need some filter that makes Undefined
disappear so that it shows me as the first value: Harold Lloyd
.
I have previously performed the following operation:
//unwind
db.getCollection("Tarea").find({})
fase1 = { $unwind: "$cast"}
etapas = [fase1]
db.Tarea.aggregate( etapas )
//out
fase1 = { $unwind: "$cast" }
query2 = { "_id": 0 }
fase2 = { $project: query2 }
fase3 = { $out: "actors" }
etapas = [ fase1, fase2, fase3 ]
db.Tarea.aggregate( etapas )
And now I have a new collection called 'actors'.