✅ – Script – 21-27 Dec 11

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) => { })
const gig = await Gig.findById(req.gigId)
.populate("proposals")
.then(async (res) => { })
S
Script491d ago
answer:
const gig = await Gig.findById(req.gigId).populate({
path: "proposals",
populate: { path: "freelancerId", model: "User" },
});
const gig = await Gig.findById(req.gigId).populate({
path: "proposals",
populate: { path: "freelancerId", model: "User" },
});
UU
Unknown User491d ago