DEV Community

Discussion on: How to use Populate in Mongoose & Node.js

Collapse
 
ishubham_g profile image
Shubham Gupta

I have another question, that we also have the option to select certain fields while using populate like
.populate({path: 'comments', select: 'content name'}). Do you have some idea that it only summons that selected field or summons the whole documents and then selects the field?

Thread Thread
 
paras594 profile image
Paras 🧙‍♂️

Honestly I don't have idea about this one. But I can say that returning whole docs is easier because it doesn't have to convert it to partial one and return BSON data directly. So selecting specific fields adds an overhead. Don't let it discourage you from using select in populate or find.