'Need help about mongodb populate function

Can anyone explain what this piece of code does?

isChat = await User.populate(isChat, {
  path: "latestMessage.sender",
  select: "name profilePic",
});

Full Code is given below:-

let isChat = await Conversation.find({
  isGroupChat: false,
  $and: [
    { users: { $elemMatch: { $eq: req.user._id } } },
    { users: { $elemMatch: { $eq: userId } } },
  ],
})
 .populate("users", "-password")
 .populate("latestMessage");

isChat = await User.populate(isChat, {
  path: "latestMessage.sender",
  select: "name pic email",
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source