R
Reactiflux

help-js

✅ – Script – 21-27 Dec 11

Sscript455912/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) => { })

answer:
const gig = await Gig.findById(req.gigId).populate({
    path: "proposals",
    populate: { path: "freelancerId", model: "User" },
  });
UUUnknown User12/12/2022
3 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!