Skip to content

Instantly share code, notes, and snippets.

@aguileraq
Created September 7, 2018 20:09
Show Gist options
  • Save aguileraq/100e90e8a66bf152cd88cb48b70f7247 to your computer and use it in GitHub Desktop.
Save aguileraq/100e90e8a66bf152cd88cb48b70f7247 to your computer and use it in GitHub Desktop.
/*code*/
exports.index = (req, res, next) => {
let empresasId = req.user.empresas;
Incidencia.find({})
.populate('Historial')
.exec()
.then(incidencias =>{
res.json({
incidencias
});
})
.catch(err => {
res.status(500).json({
error: err
});
});
}
Resultado:
"incidencias":[
{
"_id":"5b92ad851585cc380c172945",
"incidencia":"llegó 5 minutos tarde",
"fecha":"07-09-2018, 11:55:33 am",
"valor":3,
"historial":"5b846fb32a675e09807b8478",
"__v":0,
"estatus":true
},
{
"_id":"5b92b86061cb193c3019f147",
"incidencia":"Mi pedido llegó 15 minutos tarde",
"fecha":"07-09-2018, 12:41:52 pm",
"valor":2,
"historial":"5b804f2d3c7d2130e8caa351",
"__v":0,
"estatus":true
},
{
"_id":"5b92bce92667be1130cdb9e1",
"incidencia":"probando probando ando!!!",
"fecha":"07-09-2018, 1:01:13 pm",
"valor":2,
"historial":"5b7f1d5b30f1b677a921c8e7",
"__v":0,
"estatus":true
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment