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

260
Vistas
Fetch data from mongoose with nested mongoose calls in node js

I want to fetch all reviews related to parties and i have following code then how to merge two collection into single collection and render it to ejs file.


PartySchema:


var partySchema = mongoose.Schema({
    user_id: String,
    category: { type: String, ref: 'categories' },
    reviews: [{ type: String, ref: 'reviews' }],
    title: String,
    description: String,
    location: String,
    latitude: String,
    longitude: String,
    contact_no: Number,
    price: Number,
    email: String,
    website: String,
    video_url: String,
    facebook_url: String,
    twitter_url: String,
    youtube_url: String,
    pinterest_url: String,
    images: [{}],
    startdate: String,
    enddate: String,
    starttime: String,
    endtime: String,
    price: Number,
    duration: Number
});

ReviewSchema :


var reviewSchema = mongoose.Schema({
    user : { type: String, ref: 'users' },
    party : { type: String, ref: 'parties' },
    title: String,
    content: String
});

Route.js


app.get("/admin/ManageParties",isLoggedIn, function (req, res) {               
Party.find({}).populate('category').populate('reviews')
     .exec(function(err,_parties){
             for(var i in _parties){
                Review.find({party:_parties[i]._id},function(err,_rev){
                    console.log(_rev);
                })                
             }            
             res.render('admin/manageparties',{
                _p:_parties
             })
        })
});
over 4 years ago · Santiago Trujillo
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