Script
Script3y ago

✅ – 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) => { })
3 Replies
Script
ScriptOP3y 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" },
});
reactibot
reactibot3y ago
This question has an answer! Thank you for helping 😄 If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1051611238779584522
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1051611238779584522 Question not getting answered? Maybe it's hard to answer, or maybe you asked at a slow time. Check out these resources for help asking a good question: https://stackoverflow.com/help/how-to-ask http://wp.me/p2oIwo-26