Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!