Display an arrangement of a mongodb document in html / jade

2

Greetings, I have a problem and I do not know how to consult the elements of a document that has an arrangement and show them in Jade.

Recibo.aggregate(
{"$match":{"nombre":{"$in":req.body.listNombrePTC},"fecha":{"$gte": lastWeekDay, "$lte": today }}},
{"$group":{"_id": "$nombre", "recibos":{"$push": "$$ROOT"}}},function(error,docs){
        if(error) {throw error}
        console.log( JSON.stringify( docs, undefined, 2 ) );
        res.render("comprobacionGastos/listaSemanal",{listaRecibos: docs})
    }   
)

When that query is executed, it returns documents to me with an array each.

So, my problem is, basically, I do not know how to check those fixes in Jade to show them.

    
asked by AnesKampoz 09.02.2017 в 22:11
source

1 answer

2

Pug (formerly Jade) allows you to iterate through each and while .

Example

ul
  each cliente in clientes
  li= cliente._id
  ul
    each recibo in cliente.recibos
    li= recibo._id
    li= recibo.nombre
    li= recibo.fecha
    li= recibo.gasto
    li= recibo.concepto

It is assumed that clientes is the name of the key of the object that you have passed to render:

let clientes = /* tu consulta */;
res.render('clientes_recibos', { clientes });
    
answered by 09.02.2017 / 22:51
source