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

201
Vistas
create an get api in nodejs to join two collection based on Id like a left join

I had two collection I want to perform a kind of left join but want to perform through a router API. I am new to node js. Can you please help me in it.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

For me you have three solutions:

1) Code it yourself with Javascript and doing one function with two Api calls (not good at all)

2) You have the lookup solution which is detailed in this other post (seems the right solution)

EDIT:

3) The third solution is also in the same post and it looks like this : (what most people are doing but as optimized as option 2), it is not exactly the solution you want since it it doesnt merge both collections at once, but you end up with the same kind of data that you wanted

db.collection1.find().forEach(
    function (document) {
        document.collection2 = db.collection2.find( { "collection1": document._id  } ).toArray();
        document.collection3 = db.collection3.find( { "_id": { $in: document.collection3 }  } ).toArray();
    }
);
over 4 years ago · Santiago Trujillo 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