Reactiflux
Reactiflux

help-js

Root Question Message

Script
Script12/11/2022
gig returns an object
inside that object lies proposals which is an array of objects
in each object in the proposals array contain a user id

I am trying to populate the user's object in each of the objects in the proposals array, how do I achieve that?|
#mongoDb
  const gig = await Gig.findById(req.gigId)
    .populate("proposals")
    .then(async (res) => { })

Solution Message

Script
Script12/11/2022
answer:
const gig = await Gig.findById(req.gigId).populate({
    path: "proposals",
    populate: { path: "freelancerId", model: "User" },
  });
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy