Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
query mongo based on results of query

I have this mongoose query:

let rE = await cR.find({myid: "xxxxxx"});

now this query will return multiple results, in which I then need to query another model based off of the rE.class_id, which is returned through rE, the query above. So I do this:

let cla = await Cl.find({_id: rE.class_id});

however, that obviously doesn't work because rE.class_id gets returned as multiple objects, so placing rE.class_id just wont work. How can I get this to work?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you are trying to get all Cl models where _id = (classIds of models rE) Then you can try this one:

let rE = await cR.find({myid: "xxxxxx"});
const classIds = rE.map(r => r.classId);
let cla = await Cl.find({_id: {$in: classIds}});
about 4 years ago · Juan Pablo Isaza Denunciar

0

const data = await cR.aggregagte([
  {
    '$match': {
       myid: "xxxxxx" 
    }
  },
  {
    '$lookup': {
      'from': 'rE', 
      'localField': 'authorId', 
      'foreignField': '_id', 
      'as': 'cla'
    }
  }
]);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda