What I want to do is with the result of a find (which returns several objects to me), again doing a find in DB looking for all the records that have the id of the records that I got in the previous find (taking into account note that they are multiple objects and with different id).
in the following code will help me with the comments to explain it better:
function get(req,res){
TG.find({_teacher:req.user.sub},(err,groups)=>{
if(err){
res.status(500).send({message:'Hubo un error al crear el grupo'});
}else{
if(groups){
**// aqui intento hacer un find con el id de los objetos
provenientes del anterior find, quiero saber como
hacerlo porque en este momento groups._id me devuelve
undefined ya que son varios objetos y no solo uno**
Groups.find({_id:groups._id},(err,groups)=>{
if(err){
res.status(500).send({message:'Error al buscar los grupos'});
}else{
if(groups){
res.status(200).send({groups});
}else{
res.status(404).send({message:'No tienes grupos'});
}
}
});
}else{
res.status(404).send({message:'No tienes grupos'});
}
}
});
}
Thank you very much