showing results for - "mongodb mongoose format before get"
Jackson
28 Feb 2019
1Pedido.aggregate([
2    {
3        $match: {} // add your search here
4    },
5    {
6        $lookup: { // this is the alternative to the populate
7            from: 'clientes',
8            localField: 'cliente',
9            foreignField: '_id',
10            as: 'clientes'
11        }
12    },
13    {
14        $project: { // add all the fields you need from the collection, if you need to omit something from the query results, just don't mention it here
15            id: 1,
16            clientes: 1,
17            date: { $dateToString: { format: "%d/%m/%Y", date: "$date" } } // this will return the date in the format "dd/MM/yyyy"
18        }
19    }
20])
21